Mystery of module bindings!
Peter Rowat
peter at pelican.ucsd.edu
Mon Apr 29 15:30:29 EDT 2013
This must be a trivial question:
I have "import numpy as np" in the python startup file.
A file called mod1.py contains "def myfn..."
and inside myfn there is a call to, say, "np.convolve".
Interactively:
>python
.... (numpy imported as np)
>import mod1
>
>mod1.myfn(...)
Error: global name "np" is not known.
=======
Why is "np" not known to functions in an imported module ?
=======
I can fix this by including "import numpy as np" in any module that uses numpy
functions -- but then what is the point of having a startup file?
-- PeterR
More information about the Python-list
mailing list