Skip to content

Instantly share code, notes, and snippets.

View victor-torres's full-sized avatar
🏠
Working from home

Victor Torres victor-torres

🏠
Working from home
View GitHub Profile
@victor-torres
victor-torres / ignoring_duplicated_decorator.py
Last active August 1, 2019 23:46
How to avoid decorating a function with the same decorator again in Python
def dec(func):
_decorators = getattr(func, '_decorators', [])
if dec in _decorators:
print('Ignoring...')
return func
_decorators.append(dec)
def inner(*args, **kwargs):
print('Calling...')