On 12/29/06, tomer filiba <[EMAIL PROTECTED]> wrote:
> On 12/29/06, Jeremy Hylton <[EMAIL PROTECTED]> wrote:
> > def spam():
> > x = 5
> > class eggs(object):
> > x = 6
> > def spam(self):
> > return x
> > return eggs
> >
> > spam()().spam() should return 5.
> >
>
> the question
On 12/29/06, Jeremy Hylton <[EMAIL PROTECTED]> wrote:
> def spam():
> x = 5
> class eggs(object):
> x = 6
> def spam(self):
> return x
> return eggs
>
> spam()().spam() should return 5.
>
the question that arises is -- is this what we wanted?
if i had to read such code, where i
On 12/19/06, tomer filiba <[EMAIL PROTECTED]> wrote:
> to my understanding of the object model, the code of snippet 1
> and snippet 2 should be equivalent. a class is just a "special function"
> that returns its locals automatically and passes them to the metaclass
> constructor:
>
> --- snippet 1
tomer filiba wrote:
> to my understanding of the object model, the code of snippet 1
> and snippet 2 should be equivalent. a class is just a "special function"
> that returns its locals automatically and passes them to the metaclass
> constructor:
PEP 227 (Statically Nested Scopes) covers this in
> If you don't follow this reasoning, please write a counter-proposal
> so that people have something to shoot down.
?
i just wanted to be sure it was done on purpose, and what were the
reasons for that.
-tomer
On 12/20/06, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> tomer filiba schrieb:
tomer filiba schrieb:
> my question is, how come classes don't create cell variables, like
> normal functions?
Not sure what you mean by "how come"? Why is the implementation
reacting as it is? Because the body of class is compiled as
a global code fragment, not as a nested one.
Or why is the imp
On 12/19/06, tomer filiba <[EMAIL PROTECTED]> wrote:
> to my understanding of the object model, the code of snippet 1
> and snippet 2 should be equivalent. a class is just a "special function"
> that returns its locals automatically and passes them to the metaclass
> constructor:
>
> --- snippet 1
to my understanding of the object model, the code of snippet 1
and snippet 2 should be equivalent. a class is just a "special function"
that returns its locals automatically and passes them to the metaclass
constructor:
--- snippet 1 ---
class foo(object):
x = 5
def f(self):
print