File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55.. module :: __main__
66 :synopsis: The environment where the top-level script is run.
77
8- '__main__' is the name of the scope in which top-level code executes.
9- A module's __name__ is set equal to '__main__' when read from
8+ `` '__main__' `` is the name of the scope in which top-level code executes.
9+ A module's __name__ is set equal to `` '__main__' `` when read from
1010standard input, a script, or from an interactive prompt.
1111
1212A module can discover whether or not it is running in the main scope by
13- checking its own __name__, which allows a common idiom for conditionally
14- executing code in a module when it is run as a script or with `python
15- -m ` but not when it is imported:
13+ checking its own `` __name__ `` , which allows a common idiom for conditionally
14+ executing code in a module when it is run as a script or with `` python
15+ -m `` but not when it is imported:
1616
1717 if __name__ == "__main__":
1818 # execute only if run as a script
1919 main()
2020
2121For a package, the same effect can be achieved by including a
22- __main__.py module, the contents of which will be executed when the
23- module is run with -m .
22+ `` __main__.py `` module, the contents of which will be executed when the
23+ module is run with `` -m `` .
You can’t perform that action at this time.
0 commit comments