Finding the instance reference of an object
pjacobi.de at googlemail.com
pjacobi.de at googlemail.com
Fri Oct 31 11:42:53 EDT 2008
Instead of comparing integers:
> x = 1
> y = x # does assignment make copies?
> y += 1
> assert x == 1
> => succeeds, which implies that Python makes a copy when assigning
with lists:
> x = [1]
> y = x # does assignment make copies?
> y += [1]
> assert x == [1]
> => fails, which implies that Python uses references when assigning
Compare lists with tupels:
x = (1,)
y = x # does assignment make copies?
y += (1,)
assert x == (1,)
=> succeeds, which implies *what*?
Regards,
Peter
More information about the Python-list
mailing list