pure virtual functions in python
holger krekel
pyth at devel.trillke.net
Sun Jan 12 09:41:13 EST 2003
polux wrote:
> how to emulate them ?
> I mean, how to force a user to redifine some functions in a derivated
> class ?
class a:
def method(self):
raise NotImplementedError(
"class %s misses 'method'" % repr(self.__class__))
class b(a):
pass
b().method()
you can also use 'inspect.getabsfile(self.__class__)' to point to
the source file. This doesn't work if you define your class
on the command line.
HTH,
holger
More information about the Python-list
mailing list