Commits

Anonymous committed 721e60f

SF patch #1171417: bug fix for islice() in docs

Comments (0)

Files changed (1)

Doc/lib/libitertools.tex

   \begin{verbatim}
      def islice(iterable, *args):
          s = slice(*args)
-         next, stop, step = s.start or 0, s.stop, s.step or 1
-         for cnt, element in enumerate(iterable):
-             if cnt < next:
-                 continue
-             if stop is not None and cnt >= stop:
-                 break
-             yield element
-             next += step             
+         it = iter(xrange(s.start or 0, s.stop or sys.maxint, s.step or 1))
+         nexti = it.next()
+         for i, element in enumerate(iterable):
+             if i == nexti:
+                 yield element
+                 nexti = it.next()          
   \end{verbatim}
 \end{funcdesc}