Skip to content

Instantly share code, notes, and snippets.

@eevmanu
Created February 16, 2022 20:21
Show Gist options
  • Save eevmanu/d1cc6a07fadbb46d83d9f293e26f7c9c to your computer and use it in GitHub Desktop.
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
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