Hi Tim,

On Wed, Mar 29, 2006 at 08:45:10AM -0700, Tim Hochberg wrote:
> Ouch. Assuming the same path is followed with tuples, I think that this 
> means the following behaviour will continue:
> 
>  >>> t = (1,2,3)
>  >>> a = array([4,5,6])
>  >>> t += a
>  >>> t
> array([5, 7, 9])

I fell into the same trap at first, but no: in fact, only lists have a
special in-place addition among all the built-in objects.  Tuples fall
back to the normal addition, which means that you can only add tuples to
tuples:

    >>> t = (1,2,3)
    >>> t += [4,5,6]
    TypeError: can only concatenate tuple (not "list") to tuple

    >>> t += array([4,5,6])
    TypeError: ...

This is current behavior and it wouldn't change.


A bientot,

Armin.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to