Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fe0e1082
Commit
fe0e1082
authored
Apr 14, 2014
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#15104: add backtick code markup.
parent
afb151a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
Doc/library/__main__.rst
Doc/library/__main__.rst
+7
-7
No files found.
Doc/library/__main__.rst
View file @
fe0e1082
...
...
@@ -5,19 +5,19 @@
.. module:: __main__
:synopsis: The environment where the top-level script is run.
'__main__'
is the name of the scope in which top-level code executes.
A module's __name__ is set equal to
'__main__'
when read from
``'__main__'``
is the name of the scope in which top-level code executes.
A module's __name__ is set equal to
``'__main__'``
when read from
standard input, a script, or from an interactive prompt.
A module can discover whether or not it is running in the main scope by
checking its own
__name__
, which allows a common idiom for conditionally
executing code in a module when it is run as a script or with `python
-m` but not when it is imported:
checking its own
``__name__``
, which allows a common idiom for conditionally
executing code in a module when it is run as a script or with `
`
python
-m`
`
but not when it is imported:
if __name__ == "__main__":
# execute only if run as a script
main()
For a package, the same effect can be achieved by including a
__main__.py
module, the contents of which will be executed when the
module is run with
-m
.
``__main__.py``
module, the contents of which will be executed when the
module is run with
``-m``
.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment