Popular recipes by Jeffrey Fischer http://code.activestate.com/recipes/users/4178137/2011-05-27T23:52:28-07:00ActiveState Code RecipesClass decorator to check that methods are implemented. (Python)
2011-05-27T23:52:28-07:00Jeffrey Fischerhttp://code.activestate.com/recipes/users/4178137/http://code.activestate.com/recipes/577725-class-decorator-to-check-that-methods-are-implemen/
<p style="color: grey">
Python
recipe 577725
by <a href="/recipes/users/4178137/">Jeffrey Fischer</a>
(<a href="/recipes/tags/decorators/">decorators</a>).
Revision 2.
</p>
<p>This decorator wraps the class's __init__ function to check that provided set of methods is present on the instantiated class. This is useful for avoiding inheritance in mix-in classes. We can inherit directly from object and still make it clear what methods we expect in other classes to be combined with the mix-in.</p>
<p>Requires at least Python 2.6, which added class decorators.</p>