How about "pure virtual methods"?

Alex Martelli aleaxit at yahoo.com
Sun Dec 19 16:45:40 EST 2004


John Machin <sjmachin at lexicon.net> wrote:

> Thank you for the motivation. I now understand what it is attempting to
> do. Unfortunately it doesn't succeed. Instead of:
> 
> if v is notimplemented: abstract_methods.append(n)
> 
> you need:
> if v.im_func is notimplemented: abstract_methods.append(n)

Right, thanks -- good thing I clearly posted it was a sketch and
untested;-).  In practice it's no doubt better to mark the function as
being abstract (e.g. with a function attribute) and otherwise leave it
alone; people who are keen about abstract classes and methods often want
to be able to call such abstract methods explicitly (for dubious
reasons, but it _is_ a common practice in C++, for example -- make a
method pure virtual, and yet give it a body anyway, for the benefit of
subclasses' overriding-methods).


Alex



More information about the Python-list mailing list