[ python-Bugs-1118101 ] lists coupled

SourceForge.net noreply at sourceforge.net
Mon Feb 7 21:03:28 CET 2005


Bugs item #1118101, was opened at 2005-02-07 14:49
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1118101&group_id=5470

>Category: None
>Group: Not a Bug
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: chopf (chopf)
>Assigned to: Nobody/Anonymous (nobody)
Summary: lists coupled

Initial Comment:
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]

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2005-02-07 15:03

Message:
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


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1118101&group_id=5470


More information about the Python-bugs-list mailing list