from functools import wraps
def my_decorator(f):
    def wrapper(*args, **kwds):
        print 'Calling decorated function'
        return f(*args, **kwds)
    return wrapper

def example():
    print 'Called example function'
>>> example()
Calling decorated function
Called example function
>>> example.__name__
>>> example.__doc__

Without the use of this decorator factory, the name of the example function would have been wrapper, and the docstring of the original example() would have been lost.