var or inout parm?

sturlamolden sturlamolden at yahoo.no
Fri Dec 12 08:39:35 EST 2008


On Dec 12, 2:34 pm, Hrvoje Niksic <hnik... at xemacs.org> wrote:

> >>> import numpy
> >>> t = (numpy.zeros(10),)
> >>> t
>
> (array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]),)>>> t[0] += 1
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: 'tuple' object does not support item assignment
>
> Of course, the side effect occurs before the exception, so:
>
> >>> t[0]

> array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.])


Actually I would consider this to be a bug. The tuple is immutable,
but no mutation of the tuple is ever attempted.

Sturla Molden






More information about the Python-list mailing list