Skip to content

Instantly share code, notes, and snippets.

@r3dm1ke
Last active October 26, 2020 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r3dm1ke/17b20a7bd5a5c47f9ee023197689675f to your computer and use it in GitHub Desktop.
Save r3dm1ke/17b20a7bd5a5c47f9ee023197689675f to your computer and use it in GitHub Desktop.
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
@devanghingu
Copy link

you forget to pass argument in line 16 😄

@devanghingu
Copy link

Actually i was read your blog in medium and found that.

@r3dm1ke
Copy link
Author

r3dm1ke commented Oct 26, 2020

you forget to pass argument in line 16 😄

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment