]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] Fix docstring and var name of itertools recipe (GH-112113) (#112311)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 22 Nov 2023 05:41:51 +0000 (06:41 +0100)
committerGitHub <noreply@github.com>
Wed, 22 Nov 2023 05:41:51 +0000 (05:41 +0000)
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 6c47eaccfa2550c140a24bc6e520d968731d9689)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Doc/library/itertools.rst

index 2196e53502f5a4491398a7fd9f35da1a510e9953..24e2684496c07503d6cfab90092ca8ee8110dfd0 100644 (file)
@@ -758,10 +758,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), ..."