Nested scopes and class variables
Steven Bethard
steven.bethard at gmail.com
Thu Feb 3 14:42:25 EST 2005
I wrote:
> Alex Martelli wrote:
>> See the difference? In a function, the 'x = x' compiles into LOAD_FAST,
>> STORE_FAST, which only looks at locals and nowhere else. In a
>> classbody, it compiles to LOAD_NAME, STORE_NAME, which looks at locals
>> AND globals -- but still not at closure cells...
>
> Is there a reason why the class body doesn't look at closure cells? That
> is, are there cases where this lookup scheme is preferred to one that
> checks locals, closure cells and globals?
For anyone who's interested I found a long thread about this here:
http://mail.python.org/pipermail/python-dev/2002-April/023427.html
And a bug report here:
http://sourceforge.net/tracker/?func=detail&aid=532860&group_id=5470&atid=105470
Steve
[1] http://docs.python.org/ref/naming.html
More information about the Python-list
mailing list