In Python,
-
Is it correct that decorators in Python can change the interface of the decorated function/class, e.g. change the signature of the decorated functions and methods of decorated class? For example:
>>> def MyDecorator(func): ... def NewFunc(): ... pass ... return NewFunc ... >>> @MyDecorator ... def MyFunc(a, b, c): ... print(a,b,c) ...
-
So decorators in Python are not necessarily used for implementing the decorator design pattern as described in the book "Design Pattern" by GoF?
-
Is it a bad practice to write a decorator which change the interface of the decorated function/class?
Thanks.
Aucun commentaire:
Enregistrer un commentaire