Si tengo una función:¿Es posible reemplazar un decorador de función/método en tiempo de ejecución? [Python]
@aDecorator
def myfunc1():
# do something here
if __name__ = "__main__":
# this will call the function and will use the decorator @aDecorator
myfunc1()
# now I want the @aDecorator to be replaced with the decorator @otherDecorator
# so that when this code executes, the function no longer goes through
# @aDecorator, but instead through @otherDecorator. How can I do this?
myfunc1()
¿Es posible sustituir un decorador en tiempo de ejecución?
pero esto no va a cambiar MyFunc1(). –
Intenté usar su código, la función todavía se ejecuta con el decorador inicial. – Geo
wow ... no esperaba que esto sucediera. – miya