[Python-Dev] Re: Sets
Guido van Rossum
guido@python.org
Thu, 18 Jul 2002 14:45:41 -0400
> But what sense would it make to force sets to expose
> a __getitem__? Right now they inherit from dict and
> thus do happen to expose it, but that's really an
> implementation artefact showing through (and a good
> example of why one might like to inherit without needing
> to expose all of the superclass's interface, to tie this in
> to another recent thread -- inheritance for implementation).
>
> Ideally, sets would expose __contains__, __iter__, __len__,
> ways to add and remove elements, and perhaps (it's so in
> Greg's implementation, and I didn't touch that) set ops such
> as union, intersection &c. someset[anindex] is really a weird
> thing to have... yet sets _are_ containers!
I believe I recommended to Greg to make sets "have" a dict instead of
"being" dicts, and I think he agreed. But I guess he never got to
implementing that change.
--Guido van Rossum (home page: http://www.python.org/~guido/)