Most viewed recipes tagged "descriptor" and "metaclass"http://code.activestate.com/recipes/tags/descriptor+metaclass/views/2016-07-31T04:03:29-07:00ActiveState Code RecipesAlias class attributes (Python)
2009-06-01T01:19:55-07:00Euan Goddardhttp://code.activestate.com/recipes/users/4170559/http://code.activestate.com/recipes/576787-alias-class-attributes/
<p style="color: grey">
Python
recipe 576787
by <a href="/recipes/users/4170559/">Euan Goddard</a>
(<a href="/recipes/tags/alias/">alias</a>, <a href="/recipes/tags/attribute/">attribute</a>, <a href="/recipes/tags/class/">class</a>, <a href="/recipes/tags/descriptor/">descriptor</a>, <a href="/recipes/tags/metaclass/">metaclass</a>).
</p>
<p>The alias metaclass allows a declarative way of creating aliases to attributes on a class. The main purpose of which is to adapt classes for duck-typing (see doc-string for me detail).</p>
Emulating super() in Python 3.x using Python 2.7 (Python)
2016-07-31T04:03:29-07:00sunqingyaohttp://code.activestate.com/recipes/users/4194518/http://code.activestate.com/recipes/580694-emulating-super-in-python-3x-using-python-27/
<p style="color: grey">
Python
recipe 580694
by <a href="/recipes/users/4194518/">sunqingyao</a>
(<a href="/recipes/tags/beginner/">beginner</a>, <a href="/recipes/tags/descriptor/">descriptor</a>, <a href="/recipes/tags/metaclass/">metaclass</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/python2/">python2</a>).
</p>
<p>Depending on the name of the first argument, <code>self.__sup</code> or <code>cls.__sup</code> behaves like <code>super()</code> in Python 3, while this code is written in Python 2.7.</p>
<p>It works for both ordinary methods and class methods(static methods don't use <code>super()</code>). See my code for detailed examples:</p>