augmented arithmetic operations

Mike Carifio carifio.nospam at nospam.usys.com
Wed Mar 13 12:57:50 EST 2002


I asked the question badly and even botched the example.
Worst yet, I could have answered it for myself if I had read
the documentation a little better.

It appears that you get a simple, but useful "automatic" implementation
of __iadd__ if you've already defined __add__ (and __isub__ for __sub__
and so forth). If you decide, for whatever reason, that you'd like to
override that default, you can do so. In fact, the doc's recommendation
is to try to update self  "in place" without making intermediates and then
return the result. Which is pretty cool, actually, because you can get
your class up and running then improve it's performance at some
later date.

Blame it on newbie impatience.





More information about the Python-list mailing list