Declaring A Function Argument As Global?
eddie at holyrood.ed.ac.uk
Fri Jan 17 18:52:07 CET 2003
Tim Daneliuk <tundra at tundraware.com> writes:
>Skip Montanaro wrote:
>> I believe this should work
>> def lhandler(list):
>> list[:] = list[1:]
>'Works like a charm. But why? I thought list[:] merely makes a copy of
>something - obviously there is more to the story if it is on the LHS.
>'Care to explain the semantics here?
I think the answer you're looking for is that the contents of the two
variables are 'shared'.
>>> b[:] = [9,8,7]
[9, 8, 7]
More information about the Python-list