Add take() to examples. Tighten the islice() example
diff --git a/Doc/lib/libitertools.tex b/Doc/lib/libitertools.tex
index e146c6c..4f025e3 100644
--- a/Doc/lib/libitertools.tex
+++ b/Doc/lib/libitertools.tex
@@ -314,7 +314,7 @@
>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura',
'', 'martin', '', 'walter', '', 'samuele']
->>> for name in islice(reportlines, 3, len(reportlines), 2):
+>>> for name in islice(reportlines, 3, None, 2):
... print name.title()
...
Alex
@@ -380,4 +380,7 @@
... result = result[1:] + (elem,)
... yield result
+>>> def take(n, seq):
+... return list(islice(seq, n))
+
\end{verbatim}
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 846a690..db7e3bd 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -392,7 +392,7 @@
27
>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura', '', 'martin', '', 'walter', '', 'samuele']
->>> for name in islice(reportlines, 3, len(reportlines), 2):
+>>> for name in islice(reportlines, 3, None, 2):
... print name.title()
...
Alex
@@ -449,6 +449,9 @@
... result = result[1:] + (elem,)
... yield result
+>>> def take(n, seq):
+... return list(islice(seq, n))
+
This is not part of the examples but it tests to make sure the definitions
perform as purported.
@@ -494,6 +497,9 @@
>>> dotproduct([1,2,3], [4,5,6])
32
+>>> take(10, count())
+[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+
"""
__test__ = {'libreftest' : libreftest}