Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Use wrapper as a decorator

We can get the same result by putting @wrap as a decorator above the definition of our function.

from wrapper import wrap
import time

@wrap
def myfunc():
    print("myfunc started")
    time.sleep(1)
    print("myfunc ended")

myfunc()