from functools import wraps
def interface (fn):
@wraps
def to_be_implemented (*args):
raise Exception ("Interface '%s' is not implemented!" % fn.__name__)
return to_be_implemented
class Foo (object):
@interface
def test (self): pass
class Bar(Foo):
def test (self): pass
class Qux(Foo):
pass
Bar().test()
Qux().test()
python decorator and interface
Reply