the way of "import"

S

smalltalk

I have three files names t1.py,t2.py,t3.py in e:\test\dir1,of course
dir2 is exsit
the content of t1.py as follow:
t1.py
import os
print 'this is t1.py'
os.chdir('..\\dir2')
the content of t2.py as follow:
print "this is t2.py"
the content of t3.py as follow:
import t1
import t2


if i run t3.py in cmd of windows as follow:
python t3.py

no errors show

if i run t3.py in idle:this is t1.py
Traceback (most recent call las
File "<stdin>", line 1, in <module>
File "t3.py", line 2, in <module>
ImportError: No module named t2

can you give me a help?
 
G

Gabriel Genellina

I have three files names t1.py,t2.py,t3.py in e:\test\dir1,of course
dir2 is exsit
the content of t1.py as follow:
t1.py
import os
print 'this is t1.py'
os.chdir('..\\dir2')
the content of t2.py as follow:
print "this is t2.py"
the content of t3.py as follow:
import t1
import t2


if i run t3.py in cmd of windows as follow:
python t3.py

no errors show

if i run t3.py in idle:
this is t1.py
Traceback (most recent call las
File "<stdin>", line 1, in <module>
File "t3.py", line 2, in <module>
ImportError: No module named t2

can you give me a help?

Which Python version? Which Windows version? With IDLE from Python 2.5.1
on XP I don't get the error (and that's the right thing)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top