[Tutor] Tutor Digest, Vol 35, Issue 27

Kent Johnson kent37 at tds.net
Tue Jan 9 14:24:41 CET 2007


raghu raghu wrote:
> i have a clarification regarding built in function,in some scripts it is 
> being used and it is give n: if _name_ == '_main_'
> why this is being used in the scripts?

This is a way to include test code that runs if the module is run as a 
main program, but not if the module is imported.

Here is some more explanation:
http://diveintopython.org/getting_to_know_python/testing_modules.html
http://pyfaq.infogami.com/tutor-what-is-if-name-main-for

Kent



More information about the Tutor mailing list