[Tutor] Main program confusion

Luke Paireepinart rabidpoobear at gmail.com
Mon Feb 19 19:13:36 CET 2007

Hazlett, Les wrote:
> Thanks Kent,
> Yes, there is a run.py in the demo folder. I is the one that runs and 
> not the one in the Python25 lib.
> So, I tried to see if I could find it if I previously imported 
> everything that the code imports. It didn’t – see below:
> IDLE 1.2
> >>> import wx
> >>> import sys,os
> >>> import run
> >>> print "run module", run
> run module <module 'run' from 'C:\Python25\Lib\idlelib\run.pyc'>
> >>>
> This has been a good lesson in my learning process. Thanks everyone.
It's not finding it because you're running your code in the directory 
that IDLE is located in!
If you start a Python interpreter in the Demo directory, you will be 
able to find the file you need.
Python searches the current working directory for modules first before 
it does anything else.
Coincidentally, Idle has a module named 'run' and since the 
interpreter's current working directory is IDLE's directory,
it imports that one.
Try using the commands
import os

and import the module.
You should get the correct one, then.


More information about the Tutor mailing list