[SciPy-User] (pas de sujet)
midel
midel at sfr.fr
Fri Apr 1 08:00:54 EDT 2011
Hi everybody,
I began using scipy a few days ago and I think a long story between us is beginning ;) I come from the Matlab/Scilab world and I have no big problem using SciPy.
Well, in fact, I have one problem, that is why I come here ! I will try to explain.
I have a main program in one file "verif.py" and I want it to import functions that i have defined in another file "fonctions.py". I import Scipy in the main program but I also need the scipy functions to be available in the functions and do not manage to do so.
The main verif.py program is :
from scipy import *
from fonction import truc
a=2;
b=truc(a);
print b
fonction.py is :
from scipy import *
def truc(machin):
plouc=machin*2;
A=array([[1,2],[3,4]]);
return A
Under iPython, when I do :
run verif.py
I get an error pointing to truc(machin):
NameError: global name 'array' is not defined
WARNING: failure executing file: <verif.py>
I have no error running
run fonction.py
Which seems normal as I explicitely import scipy.
Of course I have no error if I put the function in the same file as the main code :
from scipy import *
def truc(machin):
plouc=machin*2;
A=array([[1,2],[3,4]]);
return A
a=2;
b=truc(a);
print b
runs errorless.
The most mysterious thing is that sometimes I have no error even using two separate files, but I don't see why...
Well, I am convinced that I miss something important and basic... I am lost.
midel
More information about the SciPy-User
mailing list