From a31020bec1c6b70a74290935b37953ceed8affbd Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 15 Jan 2026 19:13:18 +0000 Subject: [PATCH 1/2] gh-106318: Add examples for str.rjust() method --- Doc/library/stdtypes.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 22bc1536c1a37b..2158e87a9fb9fe 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2554,6 +2554,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, /) From fce429bd0871ff0dcc8cf561d4478fc696936a5f Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 15 Jan 2026 19:19:04 +0000 Subject: [PATCH 2/2] gh-106318: Add doctest role and 'See also' for str.zfill() --- Doc/library/stdtypes.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 2158e87a9fb9fe..c662c49dae3fd5 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2842,13 +2842,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