list.clear() missing?!?
gry at ll.mit.edu
gry at ll.mit.edu
Thu Apr 13 11:12:55 EDT 2006
A perspective that I haven't seen raised here is inheritance.
I often say
mylist = []
if I'm done with the current contents and just want a fresh list.
But the cases where I have really needed list.clear [and laboriously
looked for it and ended up with
del l[:]
were when the object was my own class that inherits from list, adding
some state and other functionality. Of course I *could* have added my
own 'clear' function member, but I *wanted* it to behave like a
standard
python list in it's role of maintaining a sequence of processing steps.
So, I end up doing
del current_process[:]
which, IMO, looks a bit queer, especially when current_process
object is a fairly elaborate data object.
More information about the Python-list
mailing list