libmain.tex 553 Bytes
Newer Older
Fred Drake's avatar
Fred Drake committed
1
\section{\module{__main__} ---
2
         Top-level script environment}
3

4
\declaremodule[main]{builtin}{__main__}
5 6
\modulesynopsis{The environment where the top-level script is run.}

7 8
This module represents the (otherwise anonymous) scope in which the
interpreter's main program executes --- commands read either from
9 10 11 12 13 14 15 16
standard input, from a script file, or from an interactive prompt.  It
is this environment in which the idiomatic ``conditional script''
stanza causes a script to run:

\begin{verbatim}
if __name__ == "__main__":
    main()
\end{verbatim}