how to clear up a List in python?

"Martin v. Löwis" martin at v.loewis.de
Sat May 27 14:06:34 CEST 2006


Duncan Smith wrote:
> chris brat wrote:
>> Doesnt this do what the original poster is try accomplish?
>>
> 
> Not what the OP asked for, no.  Clearing a list implies that list1
> should still be bound to the same list (which might be important if
> there are other names bound to the same list).  If it wasn't important
> that it be bound to the same list then I would probably go with
> linnorm's approach (which isn't really 'clearing' the list).

Sure. However, the OP still might have been happy with just discarding
the old list and creating a new one. Although he explicitly said "clear
the list", he might have meant "make it so that the variable refers to
an empty list", to which clearing the list is only one possible
solution.

Regards,
Martin



More information about the Python-list mailing list