Fix docstring and var name of itertools recipe (#112113)

`prepend()` works with arbitrary iterables, not only iterators. In fact,
the example given uses a `list`, which is iterable, but not an iterator.
This commit is contained in:
Sebastian Rittau 2023-11-22 06:35:36 +01:00 committed by GitHub
parent 4fa376b005
commit 6c47eaccfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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), ..."