Author Topic: imports  (Read 3408 times)

0 Members and 1 Guest are viewing this topic.

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
imports
« 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?

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
Re: imports
« Reply #1 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

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: imports
« Reply #2 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.