En Mon, 04 Jan 2010 04:58:54 -0300, Chris Rebert <c...@rebertia.com> escribió:
On Sun, Jan 3, 2010 at 11:51 PM, Gabriel Genellina
<gagsl-...@yahoo.com.ar> wrote:

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

Sorry, I inadvertedly posted an incomplete message. Note the last part:

In-place addition += does work:

py> a = [1,2,3]
py> a += (4,5)
py> a
[1, 2, 3, 4, 5]

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.

In that case += should not be allowed either...

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to