Reputation: 53
I have a function file from which I load my function. It is as follows:
def testFunc(A):
B = get_rate('USD', 'JPY', datetime(2020,7,8).date()) * A
return B
I also have a master file (in the same folder) from which I run everything.
from forex_python.converter import get_rate #necessary package
%run '/Users/mak/Dropbox/Python/Templates/getfx.py' #load function
testFunc(2) #run command
However, I get an error message as follows:
NameError: name 'get_rate' is not defined
If I run all the code in a single file, then it works:
from forex_python.converter import get_rate
def testFunc(A):
B = get_rate('USD', 'JPY', datetime(2020,7,8).date()) * A
return B
testFunc(2)
How do I solve my problem?
Note: The above is a simplification of my daily work flow. In reality I am dealing with much bigger files, which is why I can't simply put all the code in one file and run it.
Upvotes: 0
Views: 49
Reputation: 27547
To solve the problem, import get_rate
inside the file with the function.
Upvotes: 2