Marko Rauhamaa :
> operator.add(x, y) [...] leaves x and y intact and must return a new
> object.
Well, if the addition doesn't modify x, the method can of course return
x.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
John O'Hagan :
> The weirdest part for me is this:
>
t = ([],)
l = t[0]
l is t[0]
> True
l += [1]
t[0] += [1]
> Traceback (most recent call last):
> File "", line 1, in
> TypeError: 'tuple' object does not support item assignment
>
> Whether there is an error or not dep
On Mon, 16 Dec 2013 11:30:13 +0800
liuerfire Wang wrote:
> Just like below:
>
> In [1]: a = ([], [])
>
> In [2]: a[0].append(1)
>
> In [3]: a
> Out[3]: ([1], [])
>
> In [4]: a[0] += [1]
> ---
> TypeError
On Monday, December 16, 2013 9:27:11 AM UTC+5:30, Chris Angelico wrote:
> On Mon, Dec 16, 2013 at 2:30 PM, liuerfire Wang wrote:
> > 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.
> >
On Mon, Dec 16, 2013 at 2:30 PM, liuerfire Wang wrote:
> 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?
It's not a bug, but it's a bit con
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)
in ()
> 1 a[0] += [1]
TypeEr