Return value of an assignment statement?

Tim Roberts timr at probo.com
Sat Feb 23 17:44:30 EST 2008


Marc 'BlackJack' Rintsch <bj_666 at gmx.net> wrote:

>On Fri, 22 Feb 2008 11:00:17 -0800, Aahz wrote:
>
>> It's just too convenient to be able to write
>> 
>> L += ['foo']
>> 
>> without rebinding L.
>
><nitpick>But ``+=`` does rebind.</nitpick>

Usually, but there's an exception for lists, which a specific
implementation for += that calls "append".  Or do I misunderstand you?

C:\tmp>python
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> L = [1,2,3]
>>> id(L)
10351000
>>> L += [4]
>>> id(L)
10351000
>>>
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list