multivariable assignment

Lie Ryan lie.1296 at gmail.com
Fri Jan 1 08:03:32 EST 2010


On 1/1/2010 3:13 AM, davidj411 wrote:
> I am not sure why this behavior is this way.
> at beginning of script, i want to create a bunch of empty lists and
> use each one for its own purpose.
> however, updating one list seems to update the others.
>
>>>> a = b = c = []
>>>> a.append('1')
>>>> a.append('1')
>>>> a.append('1')
>>>> c
> ['1', '1', '1']
>>>> a
> ['1', '1', '1']
>>>> b
> ['1', '1', '1']

Every time people get confused because of how python object model works, 
I always refer them to this article: 
http://effbot.org/zone/call-by-object.htm



More information about the Python-list mailing list