Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to improve documentation for join() (str method) #66891

Closed
vy0123 mannequin opened this issue Oct 22, 2014 · 15 comments
Closed

to improve documentation for join() (str method) #66891

vy0123 mannequin opened this issue Oct 22, 2014 · 15 comments
Assignees
Labels
3.7 (EOL) end of life docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@vy0123
Copy link
Mannequin

vy0123 mannequin commented Oct 22, 2014

BPO 22702
Nosy @rhettinger, @ncoghlan, @serhiy-storchaka, @MojoVampire, @zhangyangyu, @Mariatta
PRs
  • bpo-22702: Improves documentation for str.join method #156
  • [3.5] bpo-22702: Clarify documentation of str.join & bytes.join (GH-156) #1896
  • [3.6] bpo-22702: Clarify documentation of str.join & bytes.join (GH-156) #1897
  • [2.7] bpo-22702: Clarify documentation of str.join & bytes.join (GH-156) #1898
  • Files
  • documentationForJoin.rtf: Documentation for join() (str method)
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/rhettinger'
    closed_at = <Date 2017-05-27.16:49:24.945>
    created_at = <Date 2014-10-22.22:37:21.948>
    labels = ['type-feature', '3.7', 'docs']
    title = 'to improve documentation for join() (str method)'
    updated_at = <Date 2017-06-01.02:50:00.375>
    user = 'https://bugs.python.org/vy0123'

    bugs.python.org fields:

    activity = <Date 2017-06-01.02:50:00.375>
    actor = 'Mariatta'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2017-05-27.16:49:24.945>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2014-10-22.22:37:21.948>
    creator = 'vy0123'
    dependencies = []
    files = ['36995']
    hgrepos = []
    issue_num = 22702
    keywords = []
    message_count = 15.0
    messages = ['229841', '229851', '229852', '229853', '229854', '288073', '291366', '291367', '291669', '294581', '294582', '294602', '294899', '294900', '294901']
    nosy_count = 8.0
    nosy_names = ['rhettinger', 'ncoghlan', 'docs@python', 'serhiy.storchaka', 'josh.r', 'vy0123', 'xiang.zhang', 'Mariatta']
    pr_nums = ['156', '1896', '1897', '1898']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue22702'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7']

    @vy0123
    Copy link
    Mannequin Author

    vy0123 mannequin commented Oct 22, 2014

    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--

    @vy0123 vy0123 mannequin added OS-mac type-feature A feature request or enhancement labels Oct 22, 2014
    @ned-deily ned-deily added docs Documentation in the Doc dir and removed OS-mac labels Oct 22, 2014
    @MojoVampire
    Copy link
    Mannequin

    MojoVampire mannequin commented Oct 23, 2014

    Seems awfully verbose relative to the standards of the other built-in methods. Can you explain what improvements you feel this provides? str.join isn't a particularly complex method, relative to the other str methods that have inline usage examples (e.g. the *strip methods, where it needs to be made clear that it's stripping by character, not string matching, or the interaction of arguments in str.split).

    @vy0123
    Copy link
    Mannequin Author

    vy0123 mannequin commented Oct 23, 2014

    The improvement on the original (doc v.2.7.5) lies in the removal of the repeated 'iterable' in the first sentence, and I have also shortened it to deliver only what is returned by the builtin method which was what I wanted to know without knowing how. I wrote up this reformulation as I would have like to read it. I believe the word "concatenation" is off putting to beginners without a formal background or wanting to acquire that, and there are people like me who prefer plain and simple words. "concatenation" could be used in a footnote to guide readers to more depth if that is something they want to have. The inline usage example serves to confirm what has been described/claimed.

    --original: doc v.2.7.5

    str.join(iterable)

    Return a string which is the concatenation of the strings in the iterable iterable. The separator between elements is the string providing this method.

    @rhettinger rhettinger assigned rhettinger and unassigned docspython Oct 23, 2014
    @rhettinger
    Copy link
    Contributor

    At least the "iterable iterable" should be fixed. However, as Josh said, the proposed wording is verbose. Aim for the smallest number of words that gets the job done.

    @vy0123
    Copy link
    Mannequin Author

    vy0123 mannequin commented Oct 23, 2014

    Aim for the fewest syllables in the words without losing meaning or good taste.

    @serhiy-storchaka
    Copy link
    Member

    Current documentation looks good to me and not needing changes (except fixing the doubled "iterable"). Proposed change looks incorrect to me. No parameter named "str" is provided in this method.

    See also the docstring of str.join.

    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Apr 9, 2017

    Raymond, in the review comments on #156 Xiang noted that the current apparently duplicated iterable isn't entirely redundant:

    • the first reference is to the term "iterable"
    • the second reference is to the parameter name "*iterable*"

    "Return a string which is the concatenation of the strings in the :term:`iterable` *iterable*."

    So if we're going to drop one of them, it should probably be the link to the term, rather than the parameter name:

    "Return a string which is the concatenation of the strings in *iterable*."

    Does that sound reasonable to you?

    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Apr 9, 2017

    Noting for the record: Marco Buttu proposed my suggested approach on the PR back in early March.

    @serhiy-storchaka
    Copy link
    Member

    A reference to the iterable term was added in bpo-7116 when str.join() started accepting arbitrary iterables rather than just sequences.

    @ncoghlan
    Copy link
    Contributor

    New changeset 08e2f35 by Nick Coghlan (Sanyam Khurana) in branch 'master':
    bpo-22702: Clarify documentation of str.join & bytes.join (GH-156)
    08e2f35

    @ncoghlan
    Copy link
    Contributor

    Raymond, I went ahead and accepted the patch to remove the "iterable iterable" phrasing by only referencing the parameter name and dropping the link to the term definition.

    Do you think that's sufficient to fully resolve the request here, or would you prefer to see further changes made?

    @rhettinger
    Copy link
    Contributor

    Do you think that's sufficient to fully resolve the request here,

    Thanks Nick. That will suffice.

    @Mariatta Mariatta added the 3.7 (EOL) end of life label Jun 1, 2017
    @Mariatta
    Copy link
    Member

    Mariatta commented Jun 1, 2017

    New changeset 1721b06 by Mariatta in branch '3.5':
    bpo-22702: Clarify documentation of str.join & bytes.join (GH-156) (GH-1896)
    1721b06

    @Mariatta
    Copy link
    Member

    Mariatta commented Jun 1, 2017

    New changeset 9522159 by Mariatta in branch '3.6':
    bpo-22702: Clarify documentation of str.join & bytes.join (GH-156) (GH-1897)
    9522159

    @Mariatta
    Copy link
    Member

    Mariatta commented Jun 1, 2017

    New changeset 9139f23 by Mariatta in branch '2.7':
    bpo-22702: Clarify documentation of str.join & bytes.join (GH-156) (GH-1898)
    9139f23

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants