strange list behaviour in 2.1.1

Adrian Smith adrian_p_smith at yahoo.com
Sun Aug 5 11:13:49 EDT 2001


There is a mysterious thing. I wish to take a string from the end of
one list to the beginning of another, as one might. If I do it
interactively by hand, with two lists called 'first' and 'second':

>>> second = [first[-1]] + second
>>> del first[-1]

...it works fine, but if I put it in a procedure, and call it with the
parameters 'first' and 'second':

def overflow(firstlist, secondlist):
    secondlist = [firstlist[-1]] + secondlist
    del firstlist[-1]

...the last element of 'first' gets deleted, but 'second' remains
unaltered. Is there some strange aspect of list assignment I'm
overlooking here?

--
Adrian Smith



More information about the Python-list mailing list