2011/8/15 Vitja Makarov <vitja.maka...@gmail.com>: > When creating python-class dict it seems that CPython first looks at > dict then at globals: > > A = 1 > class X: > A = A > > def y(): > A = 3 > class Y: > A = A > return Y > Y = y() > > print(X.A, Y.A) > > Will print: 1, 1 > And not: 1, 3 > > I didn't find documentation for this but if I'm correct that should be > easy to fix issue in Cython. > > Now for this code cython reports compile-time error: local variable > referenced before assignment > >
One more interesting example: A = 1 def foo(a): A = a class X: a = A A = A class Y: a = A return X, Y X, Y = foo(666) print X.a, X.A, Y.a -- vitja. _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel