Popular recipes by Shai Berger http://code.activestate.com/recipes/users/2014324/2009-07-28T13:42:32-07:00ActiveState Code RecipesDocstring inheritance decorator (Python) 2009-07-28T13:42:32-07:00Shai Bergerhttp://code.activestate.com/recipes/users/2014324/http://code.activestate.com/recipes/576862-docstring-inheritance-decorator/ <p style="color: grey"> Python recipe 576862 by <a href="/recipes/users/2014324/">Shai Berger</a> (<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/descriptor/">descriptor</a>, <a href="/recipes/tags/docstring/">docstring</a>, <a href="/recipes/tags/inheritance/">inheritance</a>, <a href="/recipes/tags/metaprogramming/">metaprogramming</a>). </p> <p>In many cases, a subclass overrides a method in a parent class, just to change its implementation; in such cases, it would be nice to preserve the overridden method's docstring. The decorator below can be used to achieve this without explicit reference to the parent class. It does this by replacing the function with a descriptor, which accesses the parent class when the method is accessed as an attribute.</p> Pythologic -- Prolog syntax in Python (Python) 2004-09-01T21:11:14-07:00Shai Bergerhttp://code.activestate.com/recipes/users/2014324/http://code.activestate.com/recipes/303057-pythologic-prolog-syntax-in-python/ <p style="color: grey"> Python recipe 303057 by <a href="/recipes/users/2014324/">Shai Berger</a> (<a href="/recipes/tags/programs/">programs</a>). </p> <p>Some of Python's powerful meta-programming features are used to enable writing Python functions which include Prolog-like statements. Such functions load a Prolog-like database. When coupled with a suitable inference engine for logic databases, this is a way to add logical programming -- the last unsupported major paradigm -- to Python. Start at the bottom of the code for an example of the enabled syntax.</p>