Created
October 9, 2024 11:56
-
-
Save AashishNandakumar/2b85aa20053962cf08c79ecd42b2448e to your computer and use it in GitHub Desktop.
Python3 - Decorators and Current Time functions
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 uppercase_converter(func): | |
def wrapper(): | |
temp_res = func() | |
return temp_res.upper() | |
return wrapper | |
# @uppercase_converter | |
def greet(): | |
return 'hello world' | |
# same as | |
print(uppercase_converter(greet)()) | |
# import time | |
# print(time.time()) # current time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment