Is this a bug?

Michael Sparks zathras at thwackety.com
Sun Apr 24 09:43:34 EDT 2005


Hi,


I've hit a corner case that I can explain to myself *why* it happens, both
under python 2.3 and python 2.4, but the following inconsistency makes me
wonder if I should log it as a bug:

First the behaviour that isn't unexpected:

>>> a=["hello"]
>>> a = a + "world"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: can only concatenate list (not "str") to list
>>> 

Which is pretty what I'd expect.

However if we do this just slightly differently:

>>> a = ["hello"]
>>> a += "world"
>>> a
['hello', 'w', 'o', 'r', 'l', 'd']

We get completely different behaviour. This strikes me as a bug - should I
log it as one, or is there a good reason for this behaviour?

Regards,


Michael.




More information about the Python-list mailing list