summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Rittau <srittau@rittau.biz>2023-11-22 05:35:36 (GMT)
committerGitHub <noreply@github.com>2023-11-22 05:35:36 (GMT)
commit6c47eaccfa2550c140a24bc6e520d968731d9689 (patch)
tree04b46e5960d833f4a84ba3987b8a86d1dfefd239
parent4fa376b0059948d4b3d994166b0dc210a4c4f8ec (diff)
downloadcpython-6c47eaccfa2550c140a24bc6e520d968731d9689.zip
cpython-6c47eaccfa2550c140a24bc6e520d968731d9689.tar.gz
cpython-6c47eaccfa2550c140a24bc6e520d968731d9689.tar.bz2
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.
-rw-r--r--Doc/library/itertools.rst6
1 files changed, 3 insertions, 3 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index f97e7f7..ebb4ebc 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -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), ..."