On Oct 2, 6:20 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > 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.
Funny, I would welcome a change in the opposite direction: drop completely the "del a[i]" syntax from the language and use an explicit (non-special) method name, e.g. a.delete(i) or a.remove(i). Having some functionality exposed through methods and some through function builtins (e.g. len()) is more than enough; having a third way through the del statement is unnecessarily perl-ish. George -- http://mail.python.org/mailman/listinfo/python-list