python needs leaning stuff from other language
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Thu Apr 2 22:35:18 EDT 2009
On Thu, 02 Apr 2009 18:40:08 -0700, Zac Burns wrote:
> Is it really worth it to not implement list.clear and answer this
> question over and over again?
>
> I see no reason that a list shouldn't have a .clear method.
The usual answer to that is that there's already two ways of clearing a
list:
del alist[:]
alist[:] = []
and we don't need a third way. Dicts and sets need a clear() method,
because there's no equivalent to slicing.
I still think that alist.clear() would be a fine addition that matches my
intuition and aesthetic sense. Alas, I'm apparently not Dutch.
BTW Zac, on this list we don't appreciate top-posting, and we encourage
people to trim the quoted replies.
--
Steven
More information about the Python-list
mailing list