Jethro added the comment: I believe Mr. Murray somehow missed the point. My point is that the very same self.tot is interpreted as two different things: instance field and class field. In another analogous case, the interpreter would be more consistent:
>>> tot = 0 >>> def addtot(x): tot+=x >>> addtot(3) If this tot is allowed to be resolved to different things, there should be no problem. Instead you get an error: Traceback (most recent call last): File "<pyshell#106>", line 1, in <module> addtot(3) File "<pyshell#105>", line 1, in addtot def addtot(x): tot += x UnboundLocalError: local variable 'tot' referenced before assignment ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23824> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com