Jethro added the comment:
I'm not confused. In my first report, I have already explained why python
behaves that way. My point is, this is not the right way to go. Because the
very same self.tot in the in-place operation self.tot+=a is first resolved to
be the class field, then an ins
Changes by Jethro :
--
resolution: not a bug ->
status: closed -> open
___
Python tracker
<http://bugs.python.org/issue23824>
___
___
Python-bugs-list
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
New submission from Jethro:
Look at this simple code:
class A:
tot = 0
def __init__(self, a):
self.tot += a
x = A(3)
print(x.tot, A.tot)
Result from print:
3 0
What the interpreter did was that it first resolved self.tot to be the class