Popular recipes by Hui Zhang http://code.activestate.com/recipes/users/4177055/2011-02-20T16:31:08-08:00ActiveState Code RecipesAttribute - easy way to define interface (Python) 2011-02-20T16:31:08-08:00Hui Zhanghttp://code.activestate.com/recipes/users/4177055/http://code.activestate.com/recipes/577579-attribute-easy-way-to-define-interface/ <p style="color: grey"> Python recipe 577579 by <a href="/recipes/users/4177055/">Hui Zhang</a> (<a href="/recipes/tags/attribute/">attribute</a>, <a href="/recipes/tags/interface/">interface</a>, <a href="/recipes/tags/property/">property</a>, <a href="/recipes/tags/python/">python</a>). Revision 2. </p> <p>it is an enhanced property</p> <pre class="prettyprint"><code> * initialize attribute in class definition scope * easily keep the attribute behaviors in sub classes. * easy to define interface. * not afraid to forget the super(klass, self).__init__(...) :P </code></pre> weak reference map (Python) 2011-02-20T16:26:38-08:00Hui Zhanghttp://code.activestate.com/recipes/users/4177055/http://code.activestate.com/recipes/577580-weak-reference-map/ <p style="color: grey"> Python recipe 577580 by <a href="/recipes/users/4177055/">Hui Zhang</a> (<a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/weakref/">weakref</a>). Revision 2. </p> <p>keep (key, value)s in a map.</p> <p>if key or value was garbage collected, remove the corresponding records.</p>