> Is there any reason for this error? Apart from "nobody cared to write the > code" > > 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 > > In-place addition += does work: > > py> a = [1,2,3] > py> a += (4,5) > py> a > [1, 2, 3, 4, 5] > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list >
I guess to expand a bit more on what I said... What should the result be? A list or a tuple? The reason += works is because the end result is clear; a list. But it is ambiguous in the case of concatenation: did you want a tuple or a list? -- http://mail.python.org/mailman/listinfo/python-list