strange side effect with lists!?
Wolfgang.Stoecher at profactor.at
Wolfgang.Stoecher at profactor.at
Wed Oct 13 07:34:40 EDT 2004
Hello,
I'm new to Python and playing around. I'm confused by the following
behaviour:
>>> l1 = [1] # define list
>>> l2 = l1 # copy of l1 ?
>>> l2,l1
([1], [1])
>>> l2.extend(l1) # only l2 should be altered !?
>>> l2,l1
([1, 1], [1, 1]) # but also l1 is altered!
So what is the policy of assignment? When is a copy of an object created?
Where to find dox on this?
thanx,
Wolfgang
More information about the Python-list
mailing list