blob: 00c7426fbae5e98b548e338bef801dbfab7782ca [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{__main__} ---
Fred Drakedd611b02000-08-17 22:31:23 +00002 Top-level script environment}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drakedd611b02000-08-17 22:31:23 +00004\declaremodule[main]{builtin}{__main__}
Fred Drakeb91e9341998-07-23 17:59:49 +00005\modulesynopsis{The environment where the top-level script is run.}
6
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00007This module represents the (otherwise anonymous) scope in which the
8interpreter's main program executes --- commands read either from
Fred Drakedd611b02000-08-17 22:31:23 +00009standard input, from a script file, or from an interactive prompt. It
10is this environment in which the idiomatic ``conditional script''
11stanza causes a script to run:
12
13\begin{verbatim}
14if __name__ == "__main__":
15 main()
16\end{verbatim}