Re: [Python-Dev] classes and cell variables question

2006-12-29 Thread Guido van Rossum
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

Re: [Python-Dev] classes and cell variables question

2006-12-29 Thread tomer filiba
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

Re: [Python-Dev] classes and cell variables question

2006-12-29 Thread Jeremy Hylton
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

Re: [Python-Dev] classes and cell variables question

2006-12-21 Thread Nick Coghlan
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

Re: [Python-Dev] classes and cell variables question

2006-12-19 Thread tomer filiba
> 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:

Re: [Python-Dev] classes and cell variables question

2006-12-19 Thread Martin v. Löwis
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

Re: [Python-Dev] classes and cell variables question

2006-12-19 Thread Guido van Rossum
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

[Python-Dev] classes and cell variables question

2006-12-19 Thread tomer filiba
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