https://github.com/python/cpython/commit/aa2c0c3acb0e648c055a1f8d373ea3e070f9a4a1
commit: aa2c0c3acb0e648c055a1f8d373ea3e070f9a4a1
branch: main
author: Adorilson Bezerra <[email protected]>
committer: hugovk <[email protected]>
date: 2026-02-26T15:41:49+02:00
summary:
gh-106318: Add examples for str.rjust() method (#143890)
files:
M Doc/library/stdtypes.rst
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 21572d6dc71d84..4451d485884987 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -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
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]