[Tutor] how do i start

Alan Gauld alan.gauld at blueyonder.co.uk
Thu Jul 22 23:16:26 CEST 2004


> hello, i'm just starting to program with python... 

Welcome to the gang... :-)

> Heres my question is run script same as run module?

A module in Python is a file. So is a script.
But if the file contains the magic line:

if __name__ == "__main__":

the behaviour will be different depending on whether you 
import it (acting as a module) or run it(acting as a script)

But basically there is no difference in Python between a module 
or a script if you run it from the command prompt:

C:\> python foo.py

More info in my tutor in the topic on Adding Style(at the bottom) 
and the Case Study under "Turning it into a module"

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld/tutor2/



More information about the Tutor mailing list