def inherits_docstring_func(f, cls=None, funcname=None):
    """A function decorator for inheriting function docstrings.

    Look to cls for the docstring to inherit.  The funcname argument
    indicates that the cls should be searched for that name instead
    of f.__name__.

    """

    name = funcname
    if not name:
        name = f.__name__
    if cls is None:
        """shouldn't get here"""

    # go for it

    if funcname:
        docstring = get_docstring((cls,), name)
    else:
        docstring = None

    if docstring is None:
        docstring = get_docstring(cls.__bases__, name)
    if docstring is None and hasattr(cls, "__implements__"):
        # for registrations on ABCs
        docstring = get_docstring(cls.__implements__, name)

    if docstring is not None:
        f.__doc__ = docstring
    return f
A function decorator for inheriting function docstrings.

    Look to cls for the docstring to inherit.  The funcname argument
    indicates that the cls should be searched for that name instead
    of f.__name__.

    
recipes/Python/577743_Using_Metaclasses_Class_Decorators_Inherit/recipe-577743.py