del and sets proposal
Aaron "Castironpi" Brady
castironpi at gmail.com
Sun Oct 5 21:28:53 CEST 2008
Bruno Desthuilliers wrote:
> Steven D'Aprano a écrit :
>> On Sat, 04 Oct 2008 18:36:28 +0200, Bruno Desthuilliers wrote:
>> Lists are the odd one out, because del alist[x] is used to remove the
>> element at position x, rather than removing an element x.
> Nope. It's perfectly consistent with dicts, where del adict[x] is used
> to remove element associated to key x, not to remove element with value
> x. Lists and dicts are both indexed collections, list being indexed by
> position and dicts by key. sets are not indexed.
> (snip remaining - I could only keep on repeating the same thing).
Which one has seniority? It's somewhat arbitrary which of 'pop' and
'remove' have which meanings in lists. You can 'remove' on index or
value in lists, key or value in dicts, and only value in sets.
I agree that you don't pass an 'index' to 'del' in dicts, you pass a
key. Does the OP also hold that dicts should grow a 'remove' method to
remove a value?
More information about the Python-list