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

reduce takes iterable, not just sequence #75265

Closed
pochmann mannequin opened this issue Jul 30, 2017 · 6 comments
Closed

reduce takes iterable, not just sequence #75265

pochmann mannequin opened this issue Jul 30, 2017 · 6 comments
Labels
3.7 (EOL) end of life docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@pochmann
Copy link
Mannequin

pochmann mannequin commented Jul 30, 2017

BPO 31082
Nosy @rhettinger, @terryjreedy, @ncoghlan, @serhiy-storchaka, @pochmann, @corona10, @ZackerySpytz
PRs
  • bpo-31082: Use "iterable" in the docstring for functools.reduce() #20796
  • 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 = None
    closed_at = <Date 2020-06-28.06:41:38.949>
    created_at = <Date 2017-07-30.21:06:27.401>
    labels = ['type-feature', '3.7', 'docs']
    title = 'reduce takes iterable, not just sequence'
    updated_at = <Date 2020-06-28.06:41:38.949>
    user = 'https://github.com/pochmann'

    bugs.python.org fields:

    activity = <Date 2020-06-28.06:41:38.949>
    actor = 'corona10'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2020-06-28.06:41:38.949>
    closer = 'corona10'
    components = ['Documentation']
    creation = <Date 2017-07-30.21:06:27.401>
    creator = 'Stefan Pochmann'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31082
    keywords = ['patch']
    message_count = 6.0
    messages = ['299520', '299768', '299771', '299825', '299974', '372496']
    nosy_count = 8.0
    nosy_names = ['rhettinger', 'terry.reedy', 'ncoghlan', 'docs@python', 'serhiy.storchaka', 'Stefan Pochmann', 'corona10', 'ZackerySpytz']
    pr_nums = ['20796']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue31082'
    versions = ['Python 3.6', 'Python 3.7']

    @pochmann
    Copy link
    Mannequin Author

    pochmann mannequin commented Jul 30, 2017

    functools.reduce has a parameter called "iterable" and it only needs to be an iterable, not a sequence.

    The paragraph documenting it says "sequence" instead of "iterable" six times:
    https://docs.python.org/3/library/functools.html#functools.reduce

    The help shown by executing "help(functools.reduce)" in Python additionally actually names the parameter "sequence" in the signature.

    @pochmann pochmann mannequin added the 3.7 (EOL) end of life label Jul 30, 2017
    @pochmann pochmann mannequin assigned docspython Jul 30, 2017
    @pochmann pochmann mannequin added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Jul 30, 2017
    @terryjreedy
    Copy link
    Member

    Serhiy, given that the parameters of reduce are currently positional only (by experiment, it has not gotten the C.A. treatment yet), can 'sequence' in the signature in the docstring be changes to 'iterable'?

    @serhiy-storchaka
    Copy link
    Member

    Yes, I think it can. But be aware that "sequence" is used not only in the signature, but in following description.

    The term "sequence" in the documentation and the docstring looks to me like a synonym of "iterable", not a reference to collections.abc.Sequence. I don't know how the wording can be improved. Maybe looking at the documentation of builtins filter, map, zip, and itertools functions can help.

    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Aug 7, 2017

    Checking older versions of the docs, it looks like we simply haven't reworded those docs since Python 2.0 (when the "list" of the 1.5 docs became "sequence" for 2.0).

    So I think the most appropriate resolution here would be to replace the current use of "sequence" with "iterable" in both the code and the documentation.

    @serhiy-storchaka
    Copy link
    Member

    The term "sequence" also is used in the docstring of itertools.starmap() (actually an iterable is accepted).

    @corona10
    Copy link
    Member

    New changeset cd3c2bd by Zackery Spytz in branch 'master':
    bpo-31082: Use "iterable" in the docstring for functools.reduce() (GH-20796)
    cd3c2bd

    @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

    4 participants