Q
qwejohn
Hello,
I am quite a newbie to Python.
I am working on Linux Fedora Core 3.
I have wrote a small program named box.py which has only a constructor:
"""box.py"""
class box:
def __init__(self):
print "in box"
This program passes running "python box.py".
I had put this program under /work/dev/mytests/new
Now I want to use it from a second python program, which
resides in a totally different path.
I had tried , in a program named test.py,
"""test.py"""
sys.path = [ '/work/dev/mytests' ] + sys.path
from new import box
class test:
def __init__(self):
print "in test"
Running python test.py
I get the following error:
Traceback (most recent call last):
File "test.py", line 6, in ?
from new import box
ImportError: cannot import name box
Any idea ?
Regards,
John
I am quite a newbie to Python.
I am working on Linux Fedora Core 3.
I have wrote a small program named box.py which has only a constructor:
"""box.py"""
class box:
def __init__(self):
print "in box"
This program passes running "python box.py".
I had put this program under /work/dev/mytests/new
Now I want to use it from a second python program, which
resides in a totally different path.
I had tried , in a program named test.py,
"""test.py"""
sys.path = [ '/work/dev/mytests' ] + sys.path
from new import box
class test:
def __init__(self):
print "in test"
Running python test.py
I get the following error:
Traceback (most recent call last):
File "test.py", line 6, in ?
from new import box
ImportError: cannot import name box
Any idea ?
Regards,
John