def inherit_docstring_from(cls):
def _doc(func):<EOL><INDENT>cls_docstring = getattr(cls, func.__name__).__doc__<EOL>func_docstring = func.__doc__<EOL>if func_docstring is None:<EOL><INDENT>func.__doc__ = cls_docstring<EOL><DEDENT>else:<EOL><INDENT>new_docstring = func_docstring % dict(super=cls_docstring)<EOL>func.__doc__ = new_docstring<EOL><DEDENT>return func<EOL><DEDENT>return _doc<EOL>
This decorator modifies the decorated function's docstring by
replacing occurrences of '%(super)s' with the docstring of the
method of the same name from the class `cls`.

If the decorated method has no docstring, it is simply given the
docstring of cls method.

Extracted from scipy.misc.doccer.