]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix docstring and var name of itertools recipe (#112113)
authorSebastian Rittau <srittau@rittau.biz>
Wed, 22 Nov 2023 05:35:36 +0000 (06:35 +0100)
committerGitHub <noreply@github.com>
Wed, 22 Nov 2023 05:35:36 +0000 (07:35 +0200)
`prepend()` works with arbitrary iterables, not only iterators. In fact,
the example given uses a `list`, which is iterable, but not an iterator.

Doc/library/itertools.rst

index f97e7f720ae4e492803274afadac404371aea9de..ebb4ebcfa7618a1e546b8551cea3e2b48282a23d 100644 (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), ..."