Is it me or a python wart
Just van Rossum
just at xs4all.nl
Fri Apr 26 06:28:10 EDT 2002
In article <C2cBaXANXSy8Ewbb at jessikat.demon.co.uk>,
Robin Becker <robin at jessikat.fsnet.co.uk> wrote:
> 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
What a coincidence:
http://www.python.org/sf/532860
http://mail.python.org/pipermail/python-dev/2002-April/023427.html
Just
More information about the Python-list
mailing list