[issue31082] reduce takes iterable, not just sequence
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 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue31082> _______________________________________
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 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue31082> _______________________________________
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 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue31082> _______________________________________
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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue31082> _______________________________________
Serhiy Storchaka added the comment: The term "sequence" also is used in the docstring of itertools.starmap() (actually an iterable is accepted). ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue31082> _______________________________________
Change by Zackery Spytz <zspytz@gmail.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 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31082> _______________________________________
Dong-hee Na <donghee.na92@gmail.com> 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... ---------- nosy: +corona10 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31082> _______________________________________
Change by Dong-hee Na <donghee.na92@gmail.com>: ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31082> _______________________________________
participants (6)
-
Dong-hee Na
-
Nick Coghlan
-
Serhiy Storchaka
-
Stefan Pochmann
-
Terry J. Reedy
-
Zackery Spytz