Declaring A Function Argument As Global?
Skip Montanaro
skip at pobox.com
Thu Jan 16 13:57:10 EST 2003
>> def lhandler(list):
>> list[:] = list[1:]
Tim> 'Works like a charm. But why?
list[:] on the left-hand side of an assignment assigns to the entire list.
It's effectively
list[0:len(list)] = rhs
See
http://www.python.org/doc/current/ref/slicings.html
http://www.python.org/doc/current/tut/node5.html#SECTION005140000000000000000
for further discussion of list slicing.
Skip
More information about the Python-list
mailing list