]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106318: Add examples for str.ljust() method (#142719)
authorAdorilson Bezerra <adorilson@gmail.com>
Tue, 16 Dec 2025 11:39:20 +0000 (11:39 +0000)
committerGitHub <noreply@github.com>
Tue, 16 Dec 2025 11:39:20 +0000 (13:39 +0200)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Doc/library/stdtypes.rst

index 5cfa888706f9b9c0e144bcac3f0beb048545de43..5a2021e31ee4e3460928b1d983744472ff17fcaa 100644 (file)
@@ -2261,6 +2261,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()