]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-106318: Add examples for str.rjust() method (GH-143890) (#145256)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 26 Feb 2026 13:48:01 +0000 (14:48 +0100)
committerGitHub <noreply@github.com>
Thu, 26 Feb 2026 13:48:01 +0000 (13:48 +0000)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
Doc/library/stdtypes.rst

index 9ef62d414edb9ac8beeddde8ed13cb9097d01bd6..61c9d008c593b44f79986d84420e745e48c2efd4 100644 (file)
@@ -2353,6 +2353,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, /)
 
@@ -2669,13 +2682,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