simple newbie question
Chad Netzer
cnetzer at mail.arc.nasa.gov
Tue Dec 10 21:36:41 EST 2002
On Tuesday 10 December 2002 18:18, eugene kim wrote:
> what's different in these two..assignment, append?
>
> listvar1 = [1]
> listvar2 = listvar1
> listvar2 = [2]
This is equivalent to:
listvar1 = [1]
listvar2 = [2]
> listvar1 = [1]
> listvar2 = listvar1
> listvar2.append(2)
This is equivalent to:
listvar1 = [1]
listvar1.append(2)
listvar2 = listvar1
Lists don't get copied when you assign them with '=', nor do they
append. They simply get a new name (in addition to any other names
for the list)
--
Bay Area Python Interest Group - http://www.baypiggies.net/
Chad Netzer
cnetzer at mail.arc.nasa.gov
More information about the Python-list
mailing list