[issue23824] in-place addition of a shadowed class field

2015-03-31 Thread Jethro
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

[issue23824] in-place addition of a shadowed class field

2015-03-31 Thread Jethro
Changes by Jethro : -- resolution: not a bug -> status: closed -> open ___ Python tracker <http://bugs.python.org/issue23824> ___ ___ Python-bugs-list

[issue23824] in-place addition of a shadowed class field

2015-03-31 Thread Jethro
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

[issue23824] in-place addition of a shadowed class field

2015-03-31 Thread Jethro
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