Skip to content

Instantly share code, notes, and snippets.

@manuelinfosec
Last active September 6, 2022 02:22
Show Gist options
  • Save manuelinfosec/7599947af52586e5c6b1170b2f25e97b to your computer and use it in GitHub Desktop.
Save manuelinfosec/7599947af52586e5c6b1170b2f25e97b to your computer and use it in GitHub Desktop.
def bread(func):
def wrapper():
print("</''''''\>")
func()
print("<\______/>")
return wrapper
def ingredients(func):
def wrapper():
print("#tomatoes#")
func()
print("~salad~")
return wrapper
def sandwich(food='--ham--'):
print(food)
sandwich()
# Outputs: --ham--
sandwich = bread(ingredients(sandwich))
# sandwich is now reference to the decorator
# instead of the `--ham` string.
sandwich()
# Outputs:
# </''''''\>
# #tomatoes#
# --ham--
# ~salad~
# <\______/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment