mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #26462: Doc: reduce literal_block warnings, fix syntax highlighting.
Patch by Julien Palard.
This commit is contained in:
parent
87ec85f420
commit
1050d2d0c7
47 changed files with 329 additions and 128 deletions
|
|
@ -45,7 +45,9 @@ produces either the sum or the max::
|
|||
print(args.accumulate(args.integers))
|
||||
|
||||
Assuming the Python code above is saved into a file called ``prog.py``, it can
|
||||
be run at the command line and provides useful help messages::
|
||||
be run at the command line and provides useful help messages:
|
||||
|
||||
.. code-block:: shell-session
|
||||
|
||||
$ python prog.py -h
|
||||
usage: prog.py [-h] [--sum] N [N ...]
|
||||
|
|
@ -60,7 +62,9 @@ be run at the command line and provides useful help messages::
|
|||
--sum sum the integers (default: find the max)
|
||||
|
||||
When run with the appropriate arguments, it prints either the sum or the max of
|
||||
the command-line integers::
|
||||
the command-line integers:
|
||||
|
||||
.. code-block:: shell-session
|
||||
|
||||
$ python prog.py 1 2 3 4
|
||||
4
|
||||
|
|
@ -68,7 +72,9 @@ the command-line integers::
|
|||
$ python prog.py 1 2 3 4 --sum
|
||||
10
|
||||
|
||||
If invalid arguments are passed in, it will issue an error::
|
||||
If invalid arguments are passed in, it will issue an error:
|
||||
|
||||
.. code-block:: shell-session
|
||||
|
||||
$ python prog.py a b c
|
||||
usage: prog.py [-h] [--sum] N [N ...]
|
||||
|
|
@ -194,7 +200,9 @@ invoked on the command line. For example, consider a file named
|
|||
args = parser.parse_args()
|
||||
|
||||
The help for this program will display ``myprogram.py`` as the program name
|
||||
(regardless of where the program was invoked from)::
|
||||
(regardless of where the program was invoked from):
|
||||
|
||||
.. code-block:: shell-session
|
||||
|
||||
$ python myprogram.py --help
|
||||
usage: myprogram.py [-h] [--foo FOO]
|
||||
|
|
@ -596,7 +604,9 @@ the parser's help message. For example, consider a file named
|
|||
args = parser.parse_args()
|
||||
|
||||
If ``-h`` or ``--help`` is supplied at the command line, the ArgumentParser
|
||||
help will be printed::
|
||||
help will be printed:
|
||||
|
||||
.. code-block:: shell-session
|
||||
|
||||
$ python myprogram.py --help
|
||||
usage: myprogram.py [-h] [--foo FOO]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue