file 1
def file1_fun():
file2
from file1 import file1_fun
def deco(target):
"Decorated"Yes")
def wrapper():
Sentences to execute first
result = target()
Sentences to run later
return wrapper
@deco
file1_fun() <----------------- This doesn't make sense. It's not the Declaration, it's the Executive Branch.
Like this, how can you cover a decorator if you simply import an externally declared file?
python decorator
Self-answer
from file1 import file1_fun
file1_fun = deco(file1_fun)
https://stackoverflow.com/questions/25829364/applying-a-decorator-to-an-imported-function
© 2024 OneMinuteCode. All rights reserved.