[Python-3000] Iterators for dict keys, values, and items == annoying :)

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 30 02:05:04 CEST 2006


Adam DePrince wrote:

> SetView implements:
>    .__contains__
>    .add
>    .discard  
>    .__len__

But what would there be to inherit from the mixin?
Each view class will have entirely its own implementation
of these, depending on the details of the base object.
Inheritance in Python is *entirely* about implementation
inheritance, not interface inheritance.

> By allowing dict.keys() to announce "I'm a SetView"

If you mean to make it possible for code to do

   if isinstance(something, SetView):
     ...

that's another thing that Python tries to stay away
from as much as possible.

If what you're proposing is purely a conceptual
classification, I still think it's far too
elaborate. Anyone reading such a specification is
going to have their eyes glaze over within a few
milliseconds.

--
Greg


More information about the Python-3000 mailing list