Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 10, 2019 08:05
Show Gist options
  • Save Robofied/cd752690d307980d2736edaf051dcd3f to your computer and use it in GitHub Desktop.
Save Robofied/cd752690d307980d2736edaf051dcd3f to your computer and use it in GitHub Desktop.
Intermediate Python
""" defining a nested function, in that inner function i.e, a wrapper function is calling the passed function in outer function
"""
def company(decorated_function):
def wrapper_function():
print('Wrapper function is executed first')
## calling the decorator function
return decorated_function()
return wrapper_function
## creating a decorated function
def new_employee():
print('Hi! Welcome to Robofied team')
## calling a outer function by passsing the created decorated function,
func = company(new_employee)
print(func())
Wrapper function is executed first
Hi! Welcome to Robofied team
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment