Python decorator: Example 1

5th May 2023 at 5:02pm
def add_header_footer(func):
    def foo1():         
        print("header")
        func()
        print("footer")
    return(foo1)

@add_header_footer
def foo():
    print("plotting code")
    
>>> foo()
header
plotting code
footer