Kaydet (Commit) ec113af0 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

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

üst 680db018
......@@ -252,14 +252,12 @@ by functions or loops that truncate the stream.
\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}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment