Quick actions

cmd+k|ctrl+k

Navigation

Languages

Simple Decorator: check function name

Snippet info

Language

Python

Visibility

public

Author

atymo

Created

2018-05-13T11:10:17Z

Updated

2018-07-22T15:07:51Z

def mydecorator(decorated_func):
    def wrapped(*args, **kwargs):
        print("Before decorated function")
        result = decorated_func(*args, **kwargs)
        print("After decorated function")
        return result
    return wrapped


@mydecorator
def myfunc(myarg):
    """prints some text combined with a string from argument"""
    print("my function", myarg)
    return "return value"


r = myfunc('for the Talk')
print("My func name is:", myfunc.__name__)
print("My func docstring is:", myfunc.__doc__)
print(r)
INFO