Antoon Pardon <[EMAIL PROTECTED]> writes: > Op 2005-11-04, Mike Meyer schreef <[EMAIL PROTECTED]>: >> >>> Would it be too much to ask that in a line like. >>> >>> x = x + 1. >>> >>> both x's would resolve to the same namespace? >> >> Yes. That's to much bondage for programmers who've become accustomed >> to freedom. Explain why this should be illegal: >> >>>>> class C: >> ... def __getattr__(self, name): >> ... x = 1 >> ... return locals()[name] >> ... def __setattr__(self, name, value): >> ... globals()[name] = value >> ... >>>>> o = C() >>>>> o.x = o.x + 1 >>>>> x >> 2 > > I'll answer with a contra question. > > Please explain why this is illegal. > > x = 1 > def f(): > x += 1 > > f()
It isn't illegal, it just requires a different syntax. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list