You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's because many functions in the itertools docs have funny syntax with brackets instead of correct signatures. See also #131885.
But help() and inspect.signature() will show you a correct signature:
>>> help(itertools.accumulate)
Help on class accumulate in module itertools:
class accumulate(builtins.object)
| accumulate(iterable, func=None, *, initial=None)
|
| Return series of accumulated sums (or other binary function results).
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
In this case - you are using wrong keyword name. Should be func, not function.
skirpichev
added a commit
to skirpichev/cpython
that referenced
this issue
Jun 9, 2025
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
The doc of
itertools.accumulate()
says the 2nd parameter isfunction
as shown below:But using
function
argument gets the error against the doc as shown below:So, I used
func
argument, then it works as shown below:CPython versions tested on:
3.13
Operating systems tested on:
Windows
Linked PRs
The text was updated successfully, but these errors were encountered: