On Tue, Jul 5, 2016 at 5:40 AM, Steven D'Aprano
wrote:
> On Tuesday 05 July 2016 14:41, Ian Kelly wrote:
>
>> Class definitions don't create closures like functions do. When Python
>> executes a class definition, the metaclass creates a dict, and then
>> the interpreter execs the class body using
On Tuesday 05 July 2016 14:41, Ian Kelly wrote:
> Class definitions don't create closures like functions do. When Python
> executes a class definition, the metaclass creates a dict, and then
> the interpreter execs the class body using that dict as the locals.
> The body of class A has one locals
On Mon, Jul 4, 2016 at 10:41 PM, Ian Kelly wrote:
> On Mon, Jul 4, 2016 at 9:20 PM, Steven D'Aprano wrote:
>> I got this in Python 3.6:
>>
>>
>> py> class A:
>> ... var = 999
>> ... print(var) # succeeds
>> ... class B:
>> ... x = var
>> ...
>> 999
>> Traceback (most recent c
On Mon, Jul 4, 2016 at 9:20 PM, Steven D'Aprano wrote:
> I got this in Python 3.6:
>
>
> py> class A:
> ... var = 999
> ... print(var) # succeeds
> ... class B:
> ... x = var
> ...
> 999
> Traceback (most recent call last):
> File "", line 1, in
> File "", line 3, in A
>
On Mon, Jul 4, 2016 at 9:42 PM, Paul Rubin wrote:
> Steven D'Aprano writes:
>> ... class B:
>> ... x = var
>
> x = A.var
Nope. A doesn't exist yet at this point.
--
https://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano writes:
> ... class B:
> ... x = var
x = A.var
--
https://mail.python.org/mailman/listinfo/python-list
On Tuesday, July 5, 2016 at 8:50:57 AM UTC+5:30, Steven D'Aprano wrote:
> I got this in Python 3.6:
>
>
> py> class A:
> ... var = 999
> ... print(var) # succeeds
> ... class B:
> ... x = var
> ...
> 999
> Traceback (most recent call last):
> File "", line 1, in
> File "
I got this in Python 3.6:
py> class A:
... var = 999
... print(var) # succeeds
... class B:
... x = var
...
999
Traceback (most recent call last):
File "", line 1, in
File "", line 3, in A
File "", line 4, in B
NameError: name 'var' is not defined
I expected that `va