On 22/03/12 09:57, ken brockman wrote:

PS Another odd bit, was on the python docs page. It had said that using
import File_name, without the .py would import it, but not run it. Seems
a glaring oversight not to have mentioned, what would have made it run.

Actually it does run it when you import, just not the bit after the

if __name__ = "__main__".

The point of modules is that you don't usually want them to run as a program, you import them so as to get access to the functions within them. You want to control when they are called from your own code.

So although Python imports do run the file, normally all that happens is that a few classes and functions get defined and, possibly, a few global variables get initialized.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to