Hi,
I am confused on this quite bad!!
If I have this typed in interactive python:

>>import numpy

>>def dummy():
   y=numpy.arange(1,2,0.1)
   return y

and then
>>s = dummy()
>>s
>>array[1. , 1.1,  1.2........]

 it works.

But if I have a module called example.py, whose code is

def dummy():
   y=numpy.arange(1,2,0.1)
   return y

and now if I do the following:

>>import numpy
>>from example import *
>>s=dummy()

The above sequence does not work. It gives an error saying global
variable numpy not defined.

I understand that when I import a module it gets imported after
getting compiled and therefore, the module should
have a statement "import numpy" at its start.

But what if I just want to use the function 'dummy'?

I tried the following:
from example import dummy
and then try to use the function, it still gives me 'global name numpy
not defined'!

Why is that happening?
Any pointers please.
Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to