jeremito wrote:
> I am writing a class that is intended to be subclassed. What is the
> proper way to indicate that a sub class must override a method?
>
> Thanks,
> Jeremy
Decorators to the rescue?
def must_override(f):
def t(*args):
raise NotImplementedError("You must override " + f.__name__)
return t
class Foo:
@must_override
def Bar(x,y): pass
Foo().Bar()
Traceback (most recent call last):
File "testit.py", line 14, in ?
Foo().Bar()
File "testit.py", line 5, in t
raise NotImplementedError("You must override " + f.__name__)
NotImplementedError: You must override Bar
--
http://mail.python.org/mailman/listinfo/python-list