[Tutor] Ultra basic question

alan.gauld@bt.com alan.gauld@bt.com
Thu Mar 27 13:42:03 2003


> I have some python code I can run in winpython by opening the 
> source file and clicking run.
> 
> I need to be able to run it from normal python.

C:\> python  yourscript.py

> I can start python and "import rdiff_backup" but I don't 
> know how to actually invoke it.

Depends how you've defined it. If you created a main() 
function then you also need the magic incantation:

if __name__ == "__main__": 
	main()

If the driver code is not in a main() functin but inline 
then just importing the module will execute it as will 
doing it from the OS prompt as shown above.

Alan g.
Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld/