Skip to content

Commit 6c47eac

Browse files
authored
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.
1 parent 4fa376b commit 6c47eac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/library/itertools.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,10 @@ which incur interpreter overhead.
798798
"Return first n items of the iterable as a list"
799799
return list(islice(iterable, n))
800800

801-
def prepend(value, iterator):
802-
"Prepend a single value in front of an iterator"
801+
def prepend(value, iterable):
802+
"Prepend a single value in front of an iterable"
803803
# prepend(1, [2, 3, 4]) --> 1 2 3 4
804-
return chain([value], iterator)
804+
return chain([value], iterable)
805805

806806
def tabulate(function, start=0):
807807
"Return function(0), function(1), ..."

0 commit comments

Comments
 (0)