This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: lists coupled
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: chopf, tim.peters
Priority: normal Keywords:

Created on 2005-02-07 19:49 by chopf, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg24191 - (view) Author: chopf (chopf) Date: 2005-02-07 19:49
is this normal?
>>> ================================ RESTART
================================
>>> k=[1,2]
>>> k
[1, 2]
>>> l=k
>>> l
[1, 2]
>>> l[0]='hello'
>>> l
['hello', 2]
>>> k
['hello', 2]

expected: [1,2]
msg24192 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-02-07 20:03
Logged In: YES 
user_id=31435

Yes, it's normal.  You've given two names ("l" and "k") to a 
single list object.  This is fundamental to how Python works.  
Maybe this will help:

http://effbot.org/zone/python-objects.htm
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41544
2005-02-07 19:49:10chopfcreate