Hello All,

On 31 May 2014 23:02, Michael Foord <fuzzy...@voidspace.org.uk> wrote:
>
> On 31 May 2014, at 11:13, Jonathan Hartley <tart...@tartley.com> wrote:
>
>> That's what I thought too, but:
>>
>> $ python3
>> Python 3.4.0 (default, Apr 19 2014, 12:20:10)
>> [GCC 4.8.1] on linux
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> class Some(object):
>> ...   tokens = ['a', 'b', 'c']
>> ...   untokenized = [Some.tokens.index(a) for a in ['b']]
>> ...
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File "<stdin>", line 3, in Some
>>   File "<stdin>", line 3, in <listcomp>
>> NameError: name 'Some' is not defined
>>
>
> The name Some is not bound until the class body has finished executing.

or maybe (correct me if I'm wrong) until the interpreter has finished
compiling the class (which does not happen until the end of the class
definition has been reached).

> You should just be able to access the name "tokens" from inside the class 
> body though:
>
<snips>

All the best,

John
--
_______________________________________________
python-uk mailing list
python-uk@python.org
https://mail.python.org/mailman/listinfo/python-uk

Reply via email to