Created
September 10, 2020 14:48
-
-
Save Jay-flow/c1f7707e84e5bc783380e797af4a7464 to your computer and use it in GitHub Desktop.
Decorator example code
This file contains hidden or 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 decorator_function(original_function): | |
def add_espresso(): | |
print("Add espresso") | |
return original_function() | |
return add_espresso | |
@decorator_function | |
def add_water(): | |
print("Add Water") | |
@decorator_function | |
def add_milk(): | |
print("Add Milk") | |
print("# Americano Recipe") | |
add_water() | |
print("# Latte Recipe") | |
add_milk() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment