Popular recipes by Larry Hastings http://code.activestate.com/recipes/users/2467657/2013-12-10T02:36:25-08:00ActiveState Code RecipesBound Inner Classes, Using An Alternate Approach (Python) 2011-03-24T09:47:11-07:00Larry Hastingshttp://code.activestate.com/recipes/users/2467657/http://code.activestate.com/recipes/577623-bound-inner-classes-using-an-alternate-approach/ <p style="color: grey"> Python recipe 577623 by <a href="/recipes/users/2467657/">Larry Hastings</a> (<a href="/recipes/tags/getattribute/">getattribute</a>, <a href="/recipes/tags/inheritance/">inheritance</a>). Revision 2. </p> <p>An alternate implementation approach for bound inner classes. For a description of bound inner classes, see this recipe: <a href="http://code.activestate.com/recipes/577070-bound-inner-classes/" rel="nofollow">http://code.activestate.com/recipes/577070-bound-inner-classes/</a></p> <p>This recipe works in both Python 2.6 and 3.1.</p> Bound Inner Classes (Python) 2013-12-10T02:36:25-08:00Larry Hastingshttp://code.activestate.com/recipes/users/2467657/http://code.activestate.com/recipes/577070-bound-inner-classes/ <p style="color: grey"> Python recipe 577070 by <a href="/recipes/users/2467657/">Larry Hastings</a> (<a href="/recipes/tags/class_decorator/">class_decorator</a>, <a href="/recipes/tags/descriptor/">descriptor</a>). Revision 8. </p> <p>This recipe provides the class decorator <code>BoundInnerClass</code>. The decorator makes inner classes symmetric with method calls. Functions declared inside classes become "methods", and when you call them through an object they automatically get a reference to "self". The <code>BoundInnerClass</code> decorator makes this work for inner classes: an inner class decorated with <code>BoundInnerClass</code> gets a reference to that same (now "outer") object passed in automatically to the inner class's <code>__init__</code>.</p> <p>The recipe works unchanged in Python 2.6 and 3.1, and is licensed using the Zlib license.</p>