append on lists

Alex Marandon invalid at nowhere.invalid.org
Tue Sep 16 13:22:46 CEST 2008


Armin wrote:
> Duncan Booth wrote:
> 
> The semantic of [1,2,3,4,7].append(c) and [1,2,3,4,7] + c
> (with c = [8,9]) is identical,

No it's not, + doesn't alter its operands.

 >>> a = 1
 >>> b = 2
 >>> a + b
3
 >>> a
1

Were you expecting a == 3?



More information about the Python-list mailing list