append on lists

Armin a at nospam.org
Tue Sep 16 08:23:25 EDT 2008


Alex Marandon wrote:
> 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

That's not the point :)

What's the value of 1.add(b)?  None? Or 3 ??
(if add works in the same way as append)
a + b doesn't change a,b ... but a.add(b) -> a=3



More information about the Python-list mailing list