[issue22124] Rotating items of list to left
Zachary Ware
report at bugs.python.org
Sat Aug 2 23:34:29 CEST 2014
Zachary Ware added the comment:
This is not a bug. The assignment "a = nums" doesn't create a copy of "nums", it just assigns the name "a" to the same object that "nums" refers to. Since lists are mutable, changes made to "a" are visible through the name "nums". By the time you do "a[2] = nums[0]", "nums[0]" has been reassigned.
Have a look at this article: http://nedbatchelder.com/text/names.html
Also, you may want to look at collections.deque and its rotate method.
----------
nosy: +zach.ware
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22124>
_______________________________________
More information about the Python-bugs-list
mailing list