Is this a bug?

Fredrik Lundh fredrik at pythonware.com
Sun Apr 24 11:52:36 EDT 2005


Robert Kern wrote:

> It's consistent with using a.extend("world") which is what the += is
> sugar for.
>
> In [1]:a = ['hello']
>
> In [2]:a.extend("world")
>
> In [3]:a
> Out[3]:['hello', 'w', 'o', 'r', 'l', 'd']
>
> It's a *good* thing that .extend() takes any iterable without explicit
> conversion to a list. I think that it's just a minor annoyance that the
> behavior passes on to +=.

mapping += to extend is a design mistake (I guess someone got a
little carried away).

</F>






More information about the Python-list mailing list