list.clear() missing?!?
Ville Vainio
vivainio at gmail.com
Wed Apr 12 18:20:54 EDT 2006
Raymond Hettinger wrote:
> * easier to figure-out, look-up, and remember than either s[:]=[] or
> del s[:]
Easier is an understatement - it's something you figure out
automatically. When I want to do something w/ an object, looking at its
methods (via code completion) is the very first thing.
> * the OP is shocked, SHOCKED that python got by for 16 years without
> list.clear()
I'm sure you realize I was being sarcastic...
> * learning slices is basic to the language (this lesson shouldn't be
> skipped)
Assigning to slices is much less important, and is something I always
never do (and hence forget).
> * the request is inane, the underlying problem is trivial, and the
> relevant idiom is fundamental (api expansions should be saved for rich
> new functionality and not become cluttered with infrequently used
> redundant entries)
I understand that these are the main arguments. However, as it stands
there is no one *obvious* way to clear a list in-place. I agree that
it's rare to even need it, but when you do a it's a little bit of a
surprise.
More information about the Python-list
mailing list