Is it me or a python wart
Robin Becker
robin at jessikat.fsnet.co.uk
Fri Apr 26 06:02:53 EDT 2002
With 2.2.1 I'm puzzled why the first returns the local x and the second
the global I suppose x=x rather than z=x is the problem, but don't
understand why. I opposed local scopes originally as I liked the two
scope rule, but this seems more complex than I imagined.
>>> x=2
>>> def bingo(x):
... class A:
... z=x
... def get(self):
... return self.z
... return A().get()
...
>>> bingo(4)
4
>>> def bango(x):
... class A:
... x=x
... def get(self):
... return self.x
... return A().get()
...
>>> bango(4)
2
--
Robin Becker
More information about the Python-list
mailing list