Reputation: 1
I have the following folder structure:
code\Functions\quadrature.py
code\Functions\proba.py
code\Example\test.py
In proba.py I have:
def recurCoef(...):
return ...
In quadrature.py I have:
import Functions as pc2
def quadTens(...):
coef = pc2.proba.recurCoef(...)
return ...
And finally in test.py I have
import sys
sys.path.append('../')
import Functions as pc2
test = pc2.quadrature.quadTens(...)
When I try to run test.py I get the following error:
File "..\Functions\quadrature.py", line 21, in quadTens
NameError: name 'recurCoef' is not defined
I don't really understand why, I tried to write a script in quadrature.py (out of a function) that calls pc2.proba.recurCoef then run the file for testing, and it works. So a priori the module has been correctly imported.
Upvotes: 0
Views: 86
Reputation: 94
You can change your code like this.
from code import Functions as pc2
or
from .. import Functions as pc2
Upvotes: 1