Why does python behave so? (removing list items)

Michał Bentkowski mr.ecik at gmail.com
Wed Mar 26 23:04:07 CET 2008


Why does python create a reference here, not just copy the variable?

>>> j=range(0,6)
>>> k=j
>>> del j[0]
>>> j
[1, 2, 3, 4, 5]
>>> k
[1, 2, 3, 4, 5]

Shouldn't k remain the same?

-- 
Michał Bentkowski
mr.ecik at gmail.com


More information about the Python-list mailing list