]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-106318: Add examples for str.ljust() method (GH-142719) (#142803)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 16 Dec 2025 11:45:31 +0000 (12:45 +0100)
committerGitHub <noreply@github.com>
Tue, 16 Dec 2025 11:45:31 +0000 (11:45 +0000)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Doc/library/stdtypes.rst

index 5f2f0b7a887a1f5be940441bb49fa9cb06497c31..734405af55fd62d1745f3c79374ff04f3924720b 100644 (file)
@@ -2125,6 +2125,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'.ljust(10)
+      'Python    '
+      >>> 'Python'.ljust(10, '.')
+      'Python....'
+      >>> 'Monty Python'.ljust(10, '.')
+      'Monty Python'
+
+   See also :meth:`rjust`.
+
 
 .. method:: str.lower()