Last active
October 26, 2020 15:50
-
-
Save r3dm1ke/17b20a7bd5a5c47f9ee023197689675f to your computer and use it in GitHub Desktop.
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
class Logging: | |
def __init__(self, function): | |
self.function = function | |
def __call__(self, *args, **kwargs): | |
print(f'Before {self.function.__name__}') | |
self.function(*args, **kwargs) | |
print(f'After {self.function.__name__}') | |
@Logging | |
def sum(x, y): | |
print(x + y) | |
sum(5, 2) | |
> Before sum | |
> 7 | |
> After sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!