How about "pure virtual methods"?

Alex Martelli aleaxit at yahoo.com
Thu Dec 23 19:17:11 EST 2004


Mike Meyer <mwm at mired.org> wrote:

> Noam Raphael <noamr at remove.the.dot.myrea.lbox.com> writes:
> 
> > The answer is that a subclass is guaranteed to have the same
> > *interface* as the base class. And that's what matters.
> 
> This is false. For instance:
> 
> class A(object):
>  def method(self, a):
>     print a
> 
> class B(A):
>  def method(self, a, b):
>    print a, b
> 
> B implements a different interface than A. Statically typed OO
> languages either use multi-methods or disallow changing the signature
> of an overridden method.
> 
> A tool to detect such cases would probably be almost as useful as the
> tool you've proposed.

Agreed, and besides, the two tools can usefully be one.  Look at the
inspect module for signature checking helpers...


Alex



More information about the Python-list mailing list