New submission from Stefan Pochmann:
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.
assignee: docs@python components: Documentation messages: 299520 nosy: Stefan Pochmann, docs@python priority: normal severity: normal status: open title: reduce takes iterable, not just sequence type: enhancement versions: Python 3.6, Python 3.7
Terry J. Reedy added the comment:
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'?
nosy: +serhiy.storchaka, terry.reedy
Serhiy Storchaka added the comment:
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.
nosy: +ncoghlan, rhettinger
Nick Coghlan added the comment:
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.
Change by Zackery Spytz email@example.com:
keywords: +patch nosy: +ZackerySpytz nosy_count: 6.0 -> 7.0 pull_requests: +19992 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20796
Dong-hee Na firstname.lastname@example.org added the comment:
New changeset cd3c2bdd5d53db7fe1d546543d32000070916552 by Zackery Spytz in branch 'master': bpo-31082: Use "iterable" in the docstring for functools.reduce() (GH-20796) https://github.com/python/cpython/commit/cd3c2bdd5d53db7fe1d546543d320000709...