Add vs in-place add of str to list

rs387 rstarkov at
Thu Oct 2 14:43:58 CEST 2008

On Oct 2, 8:11 am, Erik Max Francis <m... at> wrote:
> It's because the `+=` operator is doing the equivalent of calling the
> `extend` method, which treats its argument as a generic sequence, and
> doesn't enforce type.

I see. Do you know whether this is seen as a problem with the language

If so, this could be fixed by changing list.__add__ to call .extend on
the left argument if it's a list... Or, by changing __iadd__ to throw
a TypeError, whichever way around is seen as more correct/desirable.

More information about the Python-list mailing list