Created
February 10, 2019 08:05
-
-
Save Robofied/cd752690d307980d2736edaf051dcd3f to your computer and use it in GitHub Desktop.
Intermediate Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 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