[Tutor] Main program confusion
Dave Kuhlman
dkuhlman at rexx.com
Mon Feb 19 17:47:06 CET 2007
On Mon, Feb 19, 2007 at 10:15:08AM -0600, Hazlett, Les wrote:
>
> if __name__ == '__main__':
> import sys,os
> import run
> run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
>
[snip]
> if__name__=='__main__' only runs when this program file is executed.
>
> But, I can't find any reference to a module run and I don't see how the
> "run.main([" line casues
>
> the "runTest(" function to run.
Step 1 -- Find the run module. If the import of "run" succeeds,
you can find out where the module run is installed on your system
by adding a print statement:
import run
print "run module:", run
That will show you where Python is finding the run module.
And, if the import statement is failing, then you are likely to
need to install something in order to execute that sample code.
Once you have found the run module, ...
Step 2 -- Read the source in the run module. In particular, you
are looking for a function named main.
Dave
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
More information about the Tutor
mailing list