Stefan Behnel, 15.08.2011 11:34:
at least to me, the most surprising thing is this:
>>> A = 1
>>> def foo(x):
... A = x
... class X:
... a = A
... return X
...
>>> foo(2).a
2
>>> def foo(x):
... A = x
... class X:
... A = A
... return X
...
>>> foo(2).A
1
That looks pretty sick, but I would guess that the 'reasoning' behind this
is that the second case contains an assignment to A inside of the class
namespace, and assignments make a variable local to a scope, in this case,
the function scope.
Argh, sorry, I interpreted the results the wrong way around. No, I have no
idea for a serious explanation. Let's see what c.l.py brings up.
Stefan
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel