[Python-ideas] clear() method for lists

Ben Finney ben+python at benfinney.id.au
Sat Apr 4 01:33:11 CEST 2009


George Sakkis <george.sakkis at gmail.com> writes:

> On Fri, Apr 3, 2009 at 6:53 AM, Andre Roberge <andre.roberge at gmail.com> wrote:
> 
> > On the general Python list, a suggestion was made to add a clear() method to
> > list, as the "obvious" way to do
> > del some_list[:]
> > or
> > some_list[:] = []
> 
> It's obviously more explicit, but at the same it's a rather
> infrequent operation and the current ways are not particularly ugly.

More than explicit, it would make ‘clear’ the One Obvious Way To Do It
for base collection types. +1 from me.

-- 
 \          “It's a good thing we have gravity or else when birds died |
  `\             they'd just stay right up there. Hunters would be all |
_o__)                                        confused.” —Steven Wright |
Ben Finney




More information about the Python-ideas mailing list