mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
[3.12] Fix docstring and var name of itertools recipe (GH-112113) (#112310)
Fix docstring and var name of itertools recipe (GH-112113)
`prepend()` works with arbitrary iterables, not only iterators. In fact,
the example given uses a `list`, which is iterable, but not an iterator.
(cherry picked from commit 6c47eaccfa
)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This commit is contained in:
parent
298e57ab56
commit
bfc6d91c78
1 changed files with 3 additions and 3 deletions
|
@ -798,10 +798,10 @@ which incur interpreter overhead.
|
|||
"Return first n items of the iterable as a list"
|
||||
return list(islice(iterable, n))
|
||||
|
||||
def prepend(value, iterator):
|
||||
"Prepend a single value in front of an iterator"
|
||||
def prepend(value, iterable):
|
||||
"Prepend a single value in front of an iterable"
|
||||
# prepend(1, [2, 3, 4]) --> 1 2 3 4
|
||||
return chain([value], iterator)
|
||||
return chain([value], iterable)
|
||||
|
||||
def tabulate(function, start=0):
|
||||
"Return function(0), function(1), ..."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue