Static variable vs Class variable

Duncan Booth duncan.booth at invalid.invalid
Wed Oct 17 05:08:27 EDT 2007


paul.melis at gmail.com wrote:

> Curious, do you have the relevant section in the docs that describes
> this behaviour?
 
Yes, but mostly by implication. In section 3.4.7 of the docs, the sentence 
before the one you quoted says:

  These methods should attempt to do the operation in-place (modifying
  self) and return the result (which could be, but does not have to be,
  self). 

The 'does not have to be self' tells you that the result of __iadd__ is 
used, i.e there is still an assignment going on.

Just read all of that paragraph carefully. It says that if there is no 
__iadd__ method it considers calling __add__/__radd__. Nowhere does it say 
that it handles the result of calling the methods differently.



More information about the Python-list mailing list