TypeError: can only concatenate list (not "tuple") to list

Chris Rebert clp2 at rebertia.com
Mon Jan 4 02:58:54 EST 2010


On Sun, Jan 3, 2010 at 11:51 PM, Gabriel Genellina
<gagsl-py2 at yahoo.com.ar> wrote:
> This
> py> [1,2,3] + (4,5)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> TypeError: can only concatenate list (not "tuple") to list

Given that tuples are sometimes used as a poor man's object (i.e.
collection of data fields), whereas lists are not typically used that
way, I'd say it's probably a good thing an explicit type conversion is
required here.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list