On Oct 2, 8:02 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 02 Oct 2008 15:39:55 -0700, Chris Rebert wrote: > > On Thu, Oct 2, 2008 at 3:20 PM, Larry Bates <[EMAIL PROTECTED]> > > wrote: > >> 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. > > Then add subscription access too. By aliasing `__getitem__()` to > `__contains__()`. And `__setitem__()` could be implemented to add or > remove objects by assigning truth values. So hypothetically: > > >>> a = set([1, 2, 3]) > >>> a[1] > True > >>> a[4] > False > >>> a[2] = False > >>> a > set([1, 3]) > >>> a[4] = True > >>> a > set([1, 3, 4]) > >>> del a[1] > >>> a > > set([3, 4]) > > I wouldn't want that addition to `set`\s but at least it can be > implemented without introducing inconsistencies.
If set behaved that way then "del a[1]" wouldn't behave like del anymore. Normally, "del whatever" means that you can no longer use "whatever"; in this proposal you can. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list