list.clear() missing?!?

Duncan Smith buzzard at urubu.freeserve.co.uk
Tue Apr 11 14:20:15 EDT 2006


John Salerno wrote:
> Steven Bethard wrote:
> 
> 
>>     lst[:] = []
>>     lst = []
> 
> 
> What's the difference here?

>>> lst = [1,2,3]
>>> lst2 = lst
>>> lst[:] = []
>>> lst2
[]
>>> lst = [1,2,3]
>>> lst2 = lst
>>> lst = []
>>> lst2
[1, 2, 3]
>>>

Duncan



More information about the Python-list mailing list