[Tutor] Main program confusion
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)] + sys.argv[1:])
> 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:
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.
More information about the Tutor