Python switch for syntax checking

Jeff Shannon jeff at
Sat Nov 20 00:27:04 CET 2004

Bengt Richter wrote:

>On Fri, 19 Nov 2004 12:08:00 -0800, Scott David Daniels <Scott.Daniels at Acm.Org> wrote:
>>First, "python" does a syntax check anyway.  If MyApp is
>>not a main program, all you get is the syntax check.  As for main
>??? What does "not a main program mean"? I'm not sure what you mean, e.g.,

I believe that Scott is referring to the difference between a file run 
from the commandline, in which __name__ is set to "__main__", and a file 
that's imported as a module, in which __name__ is set to the name of the 
module, which is normally the filename minus the .py[c|o|d] extension.

Of course, this would also imply that Scott is presuming that one is 
following the good programming practice of not putting any significant 
code (other than function, class, and global variable definitions) at 
module level, except where protected by an 'if __name__ == "__main__":' 
statement.  That *is* good practice, and most people do it, but it's not 
required so perhaps not a safe presumption...

Jeff Shannon
Credit International

More information about the Python-list mailing list