L
liuerfire Wang
Just like below:
In [1]: a = ([], [])
In [2]: a[0].append(1)
In [3]: a
Out[3]: ([1], [])
In [4]: a[0] += [1]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-ea29ca190a4d> in <module>()
----> 1 a[0] += [1]
TypeError: 'tuple' object does not support item assignment
In [5]: a
Out[5]: ([1, 1], [])
no problem, there is an exception. But a is still changed.
is this a bug, or could anyone explain it?
thanks.
--
Best regards.
/**********************************
google+: +liuerfire <http://gplus.to/onepiece> twitter:
@liuerfire<https://twitter.com/#!/liuerfire>
蛋疼ä¸è›‹ç–¼çš„都å¯ä»¥è¯•ç€ç‚¹ä¸€ä¸‹~^_^~ <http://db.tt/YGEdRM0>
***********************************/
In [1]: a = ([], [])
In [2]: a[0].append(1)
In [3]: a
Out[3]: ([1], [])
In [4]: a[0] += [1]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-ea29ca190a4d> in <module>()
----> 1 a[0] += [1]
TypeError: 'tuple' object does not support item assignment
In [5]: a
Out[5]: ([1, 1], [])
no problem, there is an exception. But a is still changed.
is this a bug, or could anyone explain it?
thanks.
--
Best regards.
/**********************************
google+: +liuerfire <http://gplus.to/onepiece> twitter:
@liuerfire<https://twitter.com/#!/liuerfire>
蛋疼ä¸è›‹ç–¼çš„都å¯ä»¥è¯•ç€ç‚¹ä¸€ä¸‹~^_^~ <http://db.tt/YGEdRM0>
***********************************/