On Fri, Nov 14, 2008 at 01:50:59PM -0500, Brandon S. Allbery KF8NH wrote:
> WHat *is* the outermost scope in that case?  When is code in that scope 
> executed?  I could see this as being a hack to allow a module to be used 
> either directly as a main, or "use"d; the former ignoring top level scope 
> code, the latter ignoring MAIN.  I think Python has something similar.

Python names the outermost scope "__MAIN__" if the file is directly
interpreted, but it gets a name related to the filename if it is "use"d.
That outermost code is always executed, but the standard idiom to have
code that is only executed when the file is executed directly is to wrap
it in an if test that compares the name against "__MAIN__".

Reply via email to