]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106318: Add examples for str.rjust() method (#143890)
authorAdorilson Bezerra <adorilson@gmail.com>
Thu, 26 Feb 2026 13:41:49 +0000 (13:41 +0000)
committerGitHub <noreply@github.com>
Thu, 26 Feb 2026 13:41:49 +0000 (15:41 +0200)
Doc/library/stdtypes.rst

index 21572d6dc71d844d272d9803c9a4f114d85d2d01..4451d485884987157882b71c496db2d082b6f8bf 100644 (file)
@@ -2504,6 +2504,19 @@ expression support in the :mod:`re` module).
    done using the specified *fillchar* (default is an ASCII space). The
    original string is returned if *width* is less than or equal to ``len(s)``.
 
+   For example:
+
+   .. doctest::
+
+      >>> 'Python'.rjust(10)
+      '    Python'
+      >>> 'Python'.rjust(10, '.')
+      '....Python'
+      >>> 'Monty Python'.rjust(10, '.')
+      'Monty Python'
+
+   See also :meth:`ljust` and :meth:`zfill`.
+
 
 .. method:: str.rpartition(sep, /)
 
@@ -2828,13 +2841,17 @@ expression support in the :mod:`re` module).
    than before. The original string is returned if *width* is less than
    or equal to ``len(s)``.
 
-   For example::
+   For example:
+
+   .. doctest::
 
       >>> "42".zfill(5)
       '00042'
       >>> "-42".zfill(5)
       '-0042'
 
+   See also :meth:`rjust`.
+
 
 .. index::
    single: ! formatted string literal