Link to home
Start Free TrialLog in
Avatar of Russ Suter
Russ Suter

asked on

New to Python, how do I import?

I have a Python module which I have called "helpers.py".
import clr
clr.AddReference('System.Windows.Forms')
import System.Windows.Forms as SWF

def hello_world(name):
    return "Hello %s!" % (name)

def main(cmd):
    SWF.MessageBox.Show(hello_world("Fred"))
    return

Open in new window

Nice and simple and I can call it and it works.

Now I have another Python module I have called "_test.py"
import helpers
import clr
clr.AddReference('System.Windows.Forms')
import System.Windows.Forms as SWF

def main(cmd):
    SWF.MessageBox.Show(hello_world("Ethel"))
    return

Open in new window

Obviously I'm doing the import wrong because I get an error saying "No module named helpers". Both .py files are in the same directory. How do I correct my mistake?
Avatar of aikimark
aikimark
Flag of United States of America image

Try this
import helpers
import clr
import System.Windows.Forms as SWF

def main(cmd):
    clr.AddReference('System.Windows.Forms')
    SWF.MessageBox.Show(hello_world("Ethel"))
    return

Open in new window

Avatar of Russ Suter
Russ Suter

ASKER

Nope, same error
ASKER CERTIFIED SOLUTION
Avatar of Russ Suter
Russ Suter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Independent research and trial and error yielded a working solution. No working solution was provided above.