mercredi 29 juillet 2020

How to append to a decorator in Python

How do I extend an existing decorator of a third party library without changing the third-party source?

Suppose I have a decorator that follows this pattern:

@xy.dummy("ab")
def hello():
    print("hello")

Now I want to extend the decorator from @xy.dummy("ab") to @xy.dummy("ab", "cd") without modifying the third party source?

Aucun commentaire:

Enregistrer un commentaire