]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Doc: printf-style library/stdtype improvements (#16741)
authorAdorilson Bezerra <adorilson@gmail.com>
Sun, 31 Mar 2024 22:34:54 +0000 (23:34 +0100)
committerGitHub <noreply@github.com>
Sun, 31 Mar 2024 22:34:54 +0000 (22:34 +0000)
Doc/library/stdtypes.rst

index c963519f164dd228f964b7a0dec668b3325e22a4..62fc10997fc5b5d8d51f31644f048bc38d4f02ec 100644 (file)
@@ -2339,7 +2339,13 @@ String objects have one unique built-in operation: the ``%`` operator (modulo).
 This is also known as the string *formatting* or *interpolation* operator.
 Given ``format % values`` (where *format* is a string), ``%`` conversion
 specifications in *format* are replaced with zero or more elements of *values*.
-The effect is similar to using the :c:func:`sprintf` in the C language.
+The effect is similar to using the :c:func:`sprintf` function in the C language.
+For example:
+
+.. doctest::
+
+   >>> print('%s has %d quote types.' % ('Python', 2))
+   Python has 2 quote types.
 
 If *format* requires a single argument, *values* may be a single non-tuple
 object. [5]_  Otherwise, *values* must be a tuple with exactly the number of