Last active
November 27, 2019 15:02
-
-
Save dmi3coder/45b6c007f7595f7d5a6d9a165a9e65fe to your computer and use it in GitHub Desktop.
Our example of python decorators
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 as_html(func): | |
def wrapper(): | |
result = func() | |
return f'<html>{result}</html>' | |
return wrapper | |
@as_html | |
def say_hello(): | |
return 'Hello' | |
print(say_hello()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment