Python decorator: Example 1

 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

Comments

Popular posts from this blog

Communicating and downloading data from the James Webb Space Telescope