Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{__main__} --- |
Fred Drake | dd611b0 | 2000-08-17 22:31:23 +0000 | [diff] [blame] | 2 | Top-level script environment} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | |
Fred Drake | dd611b0 | 2000-08-17 22:31:23 +0000 | [diff] [blame] | 4 | \declaremodule[main]{builtin}{__main__} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 5 | \modulesynopsis{The environment where the top-level script is run.} |
| 6 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 7 | This module represents the (otherwise anonymous) scope in which the |
| 8 | interpreter's main program executes --- commands read either from |
Fred Drake | dd611b0 | 2000-08-17 22:31:23 +0000 | [diff] [blame] | 9 | standard input, from a script file, or from an interactive prompt. It |
| 10 | is this environment in which the idiomatic ``conditional script'' |
| 11 | stanza causes a script to run: |
| 12 | |
| 13 | \begin{verbatim} |
| 14 | if __name__ == "__main__": |
| 15 | main() |
| 16 | \end{verbatim} |