del and sets proposal

Larry Bates larry.bates at vitalEsafe.com
Fri Oct 3 00:20:05 CEST 2008


You can do the following:

a = [1,2,3,4,5]
del a[0]

and

a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'}
del a[1]

why doesn't it work the same for sets (particularly since sets are based on a 
dictionary)?

a = set([1,2,3,4,5])
del a[1]

Yes I know that sets have a remove method (like lists), but since dictionaries 
don't have a remove method, shouldn't sets behave like more like dictionaries 
and less like lists?  IMHO del for sets is quite intuitive.  I guess it is too 
late to change now.

-Larry



More information about the Python-list mailing list