johnny wrote:
> What is the purpose of
> if __name__ == "__main__":
> 
> If you have a module, does it get called automatically?
> 

It is a common pattern to make one and the same source file usable as a
 program and as a module. When you import some python module its
__name__ is never "__main__". When you run a python script __name__ is
always "__main__". This way you can control what shall happen when you
run the source file as a standalone program.

To put it simple: Everything in the `if __name__ == "__main__":` block
is only executed when you run the source file as a program.

Hope that helps,
-- 
Soni Bergraj
http://www.YouJoy.org/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to