Python Source Code Beautifier

Paul Boddie paul at
Mon Mar 5 11:53:59 CET 2007

On 2 Mar, 14:45, Alan Franzoni <alan.franzoni_inva... at geemail.invalid>
> I mean... I don't like that. I'm not really a Python expert, I found this
> behaviour is documented in the language reference itself:
> But... I don't know, still think it's confusing and not going to use it.

One way to think of it is this:

a += b more or less the same as...

if hasattr(a, "__iadd__"):
    a = a.__iadd__(b)
    a = a + b

Since __iadd__ might mutate an object, returning the same object, it's
possible to say that the name "a" still points to the same object in
such circumstances using the above scheme. Whether any rebinding or
resetting of "a" actually takes place in such a situation (in CPython)
might be considered an issue of optimisation, but I suppose augmented
assignments with attributes might bring out some semantic differences,
too, as can be seen by the note about class attributes at the end of
the referenced section of the manual.


More information about the Python-list mailing list