inconsistency with += between different types ?

Terry Reedy tjreedy at udel.edu
Wed Aug 7 13:19:22 EDT 2002


"Andreas Leitgeb" <Andreas.Leitgeb at siemens.at> wrote in message
> __iadd__ is SUPPOSED to modify self's attributes and then "return
self"

Only if that is the sensible thing to do.

<suggestion to enforce above semantics by ignoring actual return and
substituting self>

> This would make sure that clean implementations would stay ok, while
> those implementations, that obfuscate the design of <op>= will
hopefully
> phase out.

Python is not a nanny.  It's a language for consenting adults.  What
you do with your classes is your business.  If you use someone else's
classes, it is your responsibility to consider the sanity of the
source -- and to test.

TJR






More information about the Python-list mailing list