On Thu, Oct 2, 2008 at 3: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]
Sets don't support subscripting, so if you can't go 'a_set[something]', why would you expect to be able to be able to 'del' such an expression? What would the subscription even mean without the 'del'? It doesn't make sense and would just be inconsistent. > > 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 No, sets are a datatype unto themselves. They are based on dictionaries internally (at least in CPython), but that's an implemention detail to be hidden, not emphasized. > intuitive. I guess it is too late to change now. Most likely. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com > > -Larry > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list