python needs leaning stuff from other language

Ben Finney ben+python at benfinney.id.au
Thu Apr 2 22:52:20 EDT 2009


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:

> 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.

I think it would also be better to have One (and prefereably Only One)
Obvious Way To Do It. That obvious way, for those who work with
Python's ‘set’ and ‘dict’, is a ‘clear’ method. It seems best to have
‘list’ conform with this also.

> BTW Zac, on this list we don't appreciate top-posting, and we
> encourage people to trim the quoted replies.

<URL:http://en.wikipedia.org/wiki/Posting_style#Inline_replying>

-- 
 \          “Generally speaking, the errors in religion are dangerous; |
  `\    those in philosophy only ridiculous.” —David Hume, _A Treatise |
_o__)                                           of Human Nature_, 1739 |
Ben Finney



More information about the Python-list mailing list