namespace query

Dr Mephesto dnhkng at
Wed Apr 22 14:21:06 CEST 2009


I have a quick question about global namespace, and I'm hoping someone
could give a quick reply to sort me out :)

I have a single file program that uses numpy, and it works just fine.
I want to move some classes into their own files, to make the code
reusable.  When I cut and paste the the classes into new files, and
then "import" them back into the original program, I get an
error,:"NameError: name 'numpy' is not defined", called about the new
class files.

If I add a "global numpy" to the beginning of each class in the new
files, the program runs. Do I really have to add "global XXX" for
every module I import in the main program into every module I create
and import? Why are the class files I created not seeing the top

Thanks in Advance!


More information about the Python-list mailing list