Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
@ingredients | |
@bread | |
def strange_sandwich(food='--ham--'): | |
print(food) | |
strange_sandwich() | |
# Outputs: | |
##tomatoes# | |
#</''''''\> | |
# --ham-- |
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
@bread | |
@ingredients | |
def sandwich(food="--ham--"): | |
print(food) | |
sandwich() | |
# Outputs: | |
#</''''''\> | |
# #tomatoes# |
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
def bread(func): | |
def wrapper(): | |
print("</''''''\>") | |
func() | |
print("<\______/>") | |
return wrapper | |
def ingredients(func): | |
def wrapper(): | |
print("#tomatoes#") |
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
another_stand_alone_function = my_shiny_new_decorator(another_stand_alone_function) |
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
@my_shiny_new_decorator | |
def another_stand_alone_function(): | |
print("Leave me alone") | |
another_stand_alone_function() | |
# Outputs: | |
# Before the function runs | |
# Leave me alone | |
# After the function runs |
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
a_stand_alone_function = my_shiny_new_decorator(a_stand_alone_function) | |
a_stand_alone_function() | |
# Outputs: | |
# Before the function runs | |
# I am a stand alone function, don’t you dare modify me | |
# After the function runs |
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
a_stand_alone_function_decorated = my_shiny_new_decorator(a_stand_alone_function) | |
a_stand_alone_function_decorated() | |
# Outputs: | |
# Before the function runs | |
# I am a stand alone function, don't you dare modify me | |
# After the function runs |
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
def a_stand_alone_function(): | |
print("I am a stand alone function, don’t you dare modify me") | |
a_stand_alone_function() | |
# Outputs: I am a stand alone function, don't you dare modify me |
NewerOlder