[New-bugs-announce] [issue22702] to improve documentation for join() (str method)

Van Ly report at bugs.python.org
Thu Oct 23 00:37:21 CEST 2014


New submission from Van Ly:

This issue should go in the Documentation component but that is not an option in the issue tracker. 

Suggestion to improve documentation for join() (str method). Applies to versions 2.7.5, 3.3.6, 3.5.0a0.

--quote

str.join(iterable)

Returns a string. Uses the string str to join strings from
iterable. Raises TypeError for non-string found in iterable including
object of bytes.

>>> # the iterable consists of number
>>> try:
>>>         print "-".join([0, 1, 2, 3])
>>> except TypeError:
>>>         print "A non-string is found in the iterable."
A non-string is found in the iterable.

>>> # the iterable consists of string
>>> try:
>>>         print ", ".join(["x", "y", "z", "0", "1", "2", "3"])
>>>         print " - ".join(["x", "y", "z", "0", "1", "2", "3"])
>>>         print " + ".join(["x", "y", "z", "0", "1", "2", "3"])
>>> except TypeError:
>>>         print "A non-string is found in the iterable."
x, y, z, 0, 1, 2, 3
x - y - z - 0 - 1 - 2 - 3
x + y + z + 0 + 1 + 2 + 3

--quote--

----------
components: Macintosh
files: documentationForJoin.rtf
messages: 229841
nosy: ned.deily, ronaldoussoren, vy0123
priority: normal
severity: normal
status: open
title: to improve documentation for join() (str method)
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.5
Added file: http://bugs.python.org/file36995/documentationForJoin.rtf

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22702>
_______________________________________


More information about the New-bugs-announce mailing list