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
Larry Bates wrote:
> [EMAIL PROTECTED] wrote:
>> Hello:
>> Variable 'a' has the next values:
>> [[1,1],[2,2]]
>> and I want to take a to b as:
>> [[1,1,'='],[2,2,'=']]
>> How can I do this with only one line of instruction?
>> Thanks!!
>>
> To copy a list use:
>
> b=a[:]
>
> -Larry
Seems I may ha
[EMAIL PROTECTED] wrote in news:1161102973.920895.141500
@i42g2000cwa.googlegroups.com:
> Hello:
> Variable 'a' has the next values:
> [[1,1],[2,2]]
> and I want to take a to b as:
> [[1,1,'='],[2,2,'=']]
> How can I do this with only one line of instruction?
> Thanks!!
>
b = [[x,y,'='] for (x,y
[EMAIL PROTECTED] wrote:
> Hello:
> Variable 'a' has the next values:
> [[1,1],[2,2]]
> and I want to take a to b as:
> [[1,1,'='],[2,2,'=']]
> How can I do this with only one line of instruction?
b = [item + ['='] for item in a]
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1
[EMAIL PROTECTED] wrote:
> Hello:
> Variable 'a' has the next values:
> [[1,1],[2,2]]
> and I want to take a to b as:
> [[1,1,'='],[2,2,'=']]
> How can I do this with only one line of instruction?
> Thanks!!
>
To copy a list use:
b=a[:]
-Larry
--
http://mail.python.org/mailman/listinfo/python-l
[EMAIL PROTECTED] wrote:
> Hello:
> Variable 'a' has the next values:
> [[1,1],[2,2]]
> and I want to take a to b as:
> [[1,1,'='],[2,2,'=']]
> How can I do this with only one line of instruction?
> Thanks!!
>>> a = [[1,1], [2,2]]
>>> map( lambda x: x + ['='], a )
[[1, 1, '='], [2, 2, '=']]
>>>
Hello:
Variable 'a' has the next values:
[[1,1],[2,2]]
and I want to take a to b as:
[[1,1,'='],[2,2,'=']]
How can I do this with only one line of instruction?
Thanks!!
--
http://mail.python.org/mailman/listinfo/python-list
12 matches
Mail list logo