multivariable assignment
Andreas Waldenburger
usenot at geekmail.INVALID
Thu Dec 31 11:32:04 EST 2009
On Thu, 31 Dec 2009 08:13:35 -0800 (PST) davidj411
<davidj411 at gmail.com> 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 = []
No, you're only creating one list (and giving that one list three
names). Creating three lists would be:
a = []
b = []
c = []
or, alternatively
a, b, c = [], [], []
Just remember: Python "variables" are just names that point to the
actual data. "x = y" just means "make 'x' a synonym for 'y'".
/W
--
INVALID? DE!
More information about the Python-list
mailing list