First page Back Continue Last page Overview Image

Eine andere Art zu dekorieren

def our_decorator(func):

def function_wrapper(x):

print("Before calling " + func.__name__)

func(x)

print("After calling " + func.__name__)

return function_wrapper

@our_decorator

def foo(x):

print("Hi, foo has been called with " + str(x))

#foo = our_decorator(foo)

foo(42)

Before calling foo

Hi, foo has been called with 42

After calling foo