Created
February 16, 2022 20:21
-
-
Save eevmanu/d1cc6a07fadbb46d83d9f293e26f7c9c to your computer and use it in GitHub Desktop.
Template from Matt Harrison π§΅ talking about decorators in Python π π https://twitter.com/__mharrison__/status/1491080949647380481
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
import functools | |
def decorator(func_to_decorate): | |
@functools.wraps(func_to_decorate) | |
def wrapper(*args, **kwargs): | |
# π BEFORE π invocation | |
result = func_to_decorate(*args, **kwargs) | |
# π AFTER π invocation | |
return result | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment