Remove ambiguous part in docstring of functools.reduce()#137130
Remove ambiguous part in docstring of functools.reduce()#137130rabelux wants to merge 1 commit intopython:mainfrom
Conversation
Old description could be read that "initial" will only be used if "iterable" is empty. This is not the case. Plus include additional sentence from docs.python.org
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
This would also require to change the C extension module: cpython/Modules/_functoolsmodule.c Line 1042 in a852c7b cc @rhettinger |
|
Please let me know what you'd prefer. |
|
Personally, I think the wording is fine so I would rather not change anything. I understand the "and serves as a default when the iterable is empty" as "in particular, it serves as a default value when the iterable is empty". IOW, it's not its only role. But the new wording would remove any pre-assumption that the reader may have so it's also fine. What matters is that if we change the docstring, then we need to change the docstring at the C level as well. I don't have any thing I want personally, and I'd rather defer this to Raymond. |
I concur that the current wording is clear enough (and it matches the code equivalent that follows. @rabelux Thanks for the suggestion, but we will decline. |
To me the description of
functools.reduce()sounded like initial will only be used if iterable is empty. This is not the case. Plus I included one additional sentence that was present in https://docs.python.org/3/library/functools.html#functools.reduce but not the docstring.If this PR gets approved I suggest to also adapt the html-docs accordingly.