From 95ea035021151d6e9dd55a71675f3c451f0dc689 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 11 May 2021 20:47:30 -0300 Subject: [PATCH 1/6] [Doc] Added examples for str.join() --- Doc/library/stdtypes.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 97e7e08364e0bd..9ae39539b16b1e 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2186,9 +2186,6 @@ expression support in the :mod:`re` module). False - -.. _meth-str-join: - .. method:: str.join(iterable, /) Return a string which is the concatenation of the strings in *iterable*. @@ -2196,6 +2193,14 @@ expression support in the :mod:`re` module). *iterable*, including :class:`bytes` objects. The separator between elements is the string providing this method. + For example: + + .. doctest:: + >>> ', '.join(['spam', 'spam', 'spam']) + 'spam, spam, spam' + >>> '-'.join('Python') + 'P-y-t-h-o-n' + .. method:: str.ljust(width, fillchar=' ', /) From 0820328691191ce0b48dbf079a6cc3398fafa8b2 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 19 Oct 2025 16:57:03 -0300 Subject: [PATCH 2/6] [Doc] Add a blank line after a doctest role on str.join() Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/library/stdtypes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 9ae39539b16b1e..d6d53aab654622 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2196,6 +2196,7 @@ expression support in the :mod:`re` module). For example: .. doctest:: + >>> ', '.join(['spam', 'spam', 'spam']) 'spam, spam, spam' >>> '-'.join('Python') From 6c5e2caef1ff0c36a0897b5879658c5630115db1 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 19 Oct 2025 18:01:13 -0300 Subject: [PATCH 3/6] Update Doc/library/stdtypes.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/library/stdtypes.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index d6d53aab654622..fd61db82cc0fce 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2191,9 +2191,7 @@ expression support in the :mod:`re` module). Return a string which is the concatenation of the strings in *iterable*. A :exc:`TypeError` will be raised if there are any non-string values in *iterable*, including :class:`bytes` objects. The separator between - elements is the string providing this method. - - For example: + elements is the string providing this method. For example: .. doctest:: From 125f049ce5f0724f34b4b76d6cb80f80c313e284 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 19 Oct 2025 18:14:32 -0300 Subject: [PATCH 4/6] [Doc] Restored anchor on str.join() --- Doc/library/stdtypes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index fd61db82cc0fce..f275d92e983cc6 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2186,6 +2186,8 @@ expression support in the :mod:`re` module). False +.. _meth-str-join: + .. method:: str.join(iterable, /) Return a string which is the concatenation of the strings in *iterable*. From 311ea662381a29ffe718556477f16c6933fe6a83 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 20 Oct 2025 10:51:57 -0300 Subject: [PATCH 5/6] [Doc] Added 'See also' to split on str.join() (and vice-versa) --- Doc/library/stdtypes.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index f275d92e983cc6..58a8399ec056e4 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2202,6 +2202,8 @@ expression support in the :mod:`re` module). >>> '-'.join('Python') 'P-y-t-h-o-n' + See also :meth:`split`. + .. method:: str.ljust(width, fillchar=' ', /) @@ -2414,6 +2416,8 @@ expression support in the :mod:`re` module). >>> " foo ".split(maxsplit=0) ['foo '] + See also :meth:`join`. + .. index:: single: universal newlines; str.splitlines method From f67dbf2c2162703306c61cf9057953db6cde959f Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 20 Oct 2025 13:01:41 -0300 Subject: [PATCH 6/6] [Doc] Fix formatting in stdtypes.rst --- Doc/library/stdtypes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 58a8399ec056e4..6c8f9ae23823bd 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2186,6 +2186,7 @@ expression support in the :mod:`re` module). False + .. _meth-str-join: .. method:: str.join(iterable, /)