QuantumATK => General Questions and Answers => Topic started by: esp on January 20, 2012, 05:43
Title: imports
Post by: esp on January 20, 2012, 05:43
I wanted to organize my code where i put parameters into a parms.py file, then use the following in the main program file:
Code
from parms import *
but i am having a problem where some of my parms use NanoLanguage units, etc .. and they are not available there ... i tried importing numpy and NanoLanguage but it is not working ... how can I accomplish this?
Title: Re: imports
Post by: esp on January 20, 2012, 05:53
ok got it .. you need this:
Code
from NanoLanguage import * import numpy import pylab import ase
then you can put your parms in another file
Title: Re: imports
Post by: Anders Blom on January 20, 2012, 10:53
That's right. We're doing users a favor (perhaps) by auto-importing some modules in atkpython (those you list), but this trick only works in the main script, not in scripts you import into the main script. So in some sense it's not a favor, since it doesn't teach people the importance of module import, which is an essential part of how Python is logically built up.