Why does python behave so? (removing list items)

Waldemar Osuch waldemar.osuch at gmail.com
Wed Mar 26 23:15:21 CET 2008


On Mar 26, 4:04 pm, "Michał Bentkowski" <mr.e... at gmail.com> wrote:
> 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?

http://www.effbot.org/zone/python-list.htm



More information about the Python-list mailing list