https://github.com/python/cpython/commit/70f777daeaa899764002ebdad5c5821b660314f9
commit: 70f777daeaa899764002ebdad5c5821b660314f9
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland <[email protected]>
date: 2024-11-04T08:37:23Z
summary:

[3.12] Docs: turn getopt examples into doctests (GH-126377) (#126386)

(cherry picked from commit 0d80777981f95bbc79b146fc78b2189c82521ab9)

Co-authored-by: Erlend E. Aasland <[email protected]>

files:
M Doc/library/getopt.rst

diff --git a/Doc/library/getopt.rst b/Doc/library/getopt.rst
index ef07ce9dd2c866..13f1d9645964fd 100644
--- a/Doc/library/getopt.rst
+++ b/Doc/library/getopt.rst
@@ -92,6 +92,8 @@ exception:
 
 An example using only Unix style options:
 
+.. doctest::
+
    >>> import getopt
    >>> args = '-a -b -cfoo -d bar a1 a2'.split()
    >>> args
@@ -104,6 +106,8 @@ An example using only Unix style options:
 
 Using long option names is equally easy:
 
+.. doctest::
+
    >>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
    >>> args = s.split()
    >>> args
@@ -115,7 +119,9 @@ Using long option names is equally easy:
    >>> args
    ['a1', 'a2']
 
-In a script, typical usage is something like this::
+In a script, typical usage is something like this:
+
+.. testcode::
 
    import getopt, sys
 
@@ -145,7 +151,9 @@ In a script, typical usage is something like this::
        main()
 
 Note that an equivalent command line interface could be produced with less code
-and more informative help and error messages by using the :mod:`argparse` 
module::
+and more informative help and error messages by using the :mod:`argparse` 
module:
+
+.. testcode::
 
    import argparse
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to