/decorator-blogpost-uppercase.py Secret
Created
June 9, 2019 19:41
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 uppercase_decorator(func): | |
def wrapper(): | |
# Get the output of the original function | |
output = func() | |
# Modify the original output and return it | |
return output.upper() | |
# return the wrapper used to modify the decorated function | |
return wrapper | |
@uppercase_decorator | |
def say_hello(): | |
return 'hello' | |
>>> say_hello() | |
HELLO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment