Pure virtual functions in Python?

Aahz aahz at pythoncraft.com
Thu Feb 25 15:32:19 EST 2010


In article <38ddd614-583c-430d-b998-214bd6360eb2 at b2g2000yqi.googlegroups.com>,
lallous  <elias.bachaalany at gmail.com> wrote:
>On Feb 22, 12:42=A0am, Gregory Ewing <greg.ew... at canterbury.ac.nz>
>wrote:
>> lallouswrote:
>>>
>>> If the base defines the method and it was empty, then my C++ code
>>> would still call the function. This is not optimal because I don't
>>> want to go from C++ to Python if the _derived_ class does not
>>> implement the cb.
>>
>> I would simply not implement the method at all in the base
>> class. Then the C++ code can do an attribute lookup for
>> the method, and if it's not found, do nothing.
>
>That is what I currently do. But if I comment out the implementations
>(empty ones) then the documentation generation tool will not document
>the callbacks.

Maybe deleting the method after the class would work.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer



More information about the Python-list mailing list