[Python-Dev] Single- vs. Multi-pass iterability

Guido van Rossum guido@python.org
Mon, 15 Jul 2002 15:33:06 -0400


> > There's another issue that Jim Fulton likes to bring up, IIRC.  If
> > class Super implements IInterface, does class Sub(Super) also
> > (automatically) implement IInterface?
> >
> > I could be totally misremembering, but I believe that Jim would say
> > "no".  Class Sub would have to explicitly declare that it also
> > implements IInterface.
> 
> I fully agree with Jim.  Inheritance is often the handiest way to
> _implement_ some things, but not if it comes with a mandatory
> contract that you have to respect (specifically, supplying some
> interfaces because your superclasses supply them).

I'm happy to allow for a way to state explicitly that Sub doesn't
implement IInterface, despite deriving from Super which does.  But I
think it ought to inherit this property by default (this is in fact
what Zope does AFAIK).  Otherwise creating minor variations on a class
would be quite a pain -- you'd have to repeat all the interfaces
implemented by the base class; and what if a later version of Super
implements more interfaces?  I would think that it's much more common
to extend a class while maintaining its contract than to inherit for
implementation only, even though there are important examples of the
latter.

--Guido van Rossum (home page: http://www.python.org/~guido/)