Se ho una funzione:È possibile sostituire un decoratore di funzione/metodo in fase di esecuzione? [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()
E 'possibile sostituire un decoratore in fase di esecuzione?
Ma questo non cambierà myfunc1(). –
Ho provato a utilizzare il codice, la funzione viene comunque eseguita con il decoratore iniziale. – Geo
wow .. non mi aspettavo che succedesse. – miya