Popular recipes by Ethan Furman http://code.activestate.com/recipes/users/4177684/2011-08-12T20:24:11-07:00ActiveState Code Recipesusing `from somename.api import *` when somename is a single module (Python)
2011-08-12T20:24:11-07:00Ethan Furmanhttp://code.activestate.com/recipes/users/4177684/http://code.activestate.com/recipes/577839-using-from-somenameapi-import-when-somename-is-a-s/
<p style="color: grey">
Python
recipe 577839
by <a href="/recipes/users/4177684/">Ethan Furman</a>
(<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/import/">import</a>, <a href="/recipes/tags/modules/">modules</a>, <a href="/recipes/tags/__all__/">__all__</a>).
</p>
<p>Allow a module to export a subset of __all__, so a user can do <code>from module.api import *</code></p>
Composition of classes instead of multiple inheritance (Python)
2011-04-16T03:40:19-07:00Ethan Furmanhttp://code.activestate.com/recipes/users/4177684/http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/
<p style="color: grey">
Python
recipe 577658
by <a href="/recipes/users/4177684/">Ethan Furman</a>
(<a href="/recipes/tags/class_decorator/">class_decorator</a>, <a href="/recipes/tags/composition/">composition</a>, <a href="/recipes/tags/inheritance/">inheritance</a>, <a href="/recipes/tags/multiple_inheritance/">multiple_inheritance</a>).
</p>
<p>MI can be difficult and confusing, and if the base classes don't cooperate -- well, cooperative MI won't work.</p>
<p>One way around this is to use composition instead. This class decorator will combine the source classes with the target class, ensuring that no duplications occur (raises a TypeError if there are any).</p>