Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Would s["one"] = 1 raise an exception?

Sets don't support indexing, so it would still raise an exception. Dicts do, which is an example of them supporting more operations than sets, which is an example of why (if there is to be any subclass relation) dicts are subclasses of sets.

Edit: I suppose there's some confusion about my language above. "then sets would be dicts whose values are all None" could more helpfully read "sets would be equivalent to dicts whose...".



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: