preferred syntax for list extend?

Bernhard Herzog bh at intevation.de
Thu Apr 18 05:58:38 EDT 2002


aahz at pythoncraft.com (Aahz) writes:

> Heh. That's because of the way __iadd__ works. Immutable objects must
> return a new object with __iadd__;

Why would you want to implement __iadd__ for immutable objects? Just
__add__ (and maybe __radd__) should be enough.

> mutable objects *MAY* return self (and usually do).

Wouldn't it have been enough to assume that __iadd__ always, if defined,
modifies the object in place?

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                           http://www.mapit.de/



More information about the Python-list mailing list