This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: reduce takes iterable, not just sequence
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Stefan Pochmann, ZackerySpytz, corona10, docs@python, ncoghlan, rhettinger, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2017-07-30 21:06 by Stefan Pochmann, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20796 merged ZackerySpytz, 2020-06-11 02:16
Messages (6)
msg299520 - (view) Author: Stefan Pochmann (Stefan Pochmann) * Date: 2017-07-30 21:06
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:

The help shown by executing "help(functools.reduce)" in Python additionally actually names the parameter "sequence" in the signature.
msg299768 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-08-05 02:58
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'?
msg299771 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-05 04:26
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 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.
msg299825 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-08-07 05:20
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.
msg299974 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-09 07:38
The term "sequence" also is used in the docstring of itertools.starmap() (actually an iterable is accepted).
msg372496 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2020-06-28 06:41
New changeset cd3c2bdd5d53db7fe1d546543d32000070916552 by Zackery Spytz in branch 'master':
bpo-31082: Use "iterable" in the docstring for functools.reduce() (GH-20796)
Date User Action Args
2022-04-11 14:58:49adminsetgithub: 75265
2020-06-28 06:41:38corona10setstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-06-28 06:41:01corona10setnosy: + corona10
messages: + msg372496
2020-06-11 02:16:52ZackerySpytzsetkeywords: + patch
nosy: + ZackerySpytz

pull_requests: + pull_request19992
stage: patch review
2017-08-09 07:38:57serhiy.storchakasetmessages: + msg299974
2017-08-07 05:20:01ncoghlansetmessages: + msg299825
2017-08-05 04:26:33serhiy.storchakasetnosy: + rhettinger, ncoghlan
messages: + msg299771
2017-08-05 02:58:12terry.reedysetnosy: + terry.reedy, serhiy.storchaka
messages: + msg299768
2017-07-30 21:06:27Stefan Pochmanncreate