diff options
author | Raymond Hettinger <python@rcn.com> | 2003-05-02 19:44:20 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-05-02 19:44:20 (GMT) |
commit | 341deb74e7ec78eaf99838669ce04871e9f15783 (patch) | |
tree | c3c8257703ef5e718c8f850945dc2e7070f25071 /Doc | |
parent | 14ef54cd833c7ccfa0b3d03e2b45074d54a8ac87 (diff) | |
download | cpython-341deb74e7ec78eaf99838669ce04871e9f15783.zip cpython-341deb74e7ec78eaf99838669ce04871e9f15783.tar.gz cpython-341deb74e7ec78eaf99838669ce04871e9f15783.tar.bz2 |
The previous made the stop argument optional.
It is better to be explicit and just allow stop to be None.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libitertools.tex | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/Doc/lib/libitertools.tex b/Doc/lib/libitertools.tex index d0e1269..f291fe3 100644 --- a/Doc/lib/libitertools.tex +++ b/Doc/lib/libitertools.tex @@ -197,9 +197,9 @@ by functions or loops that truncate the stream. If \var{start} is non-zero, then elements from the iterable are skipped until start is reached. Afterward, elements are returned consecutively unless \var{step} is set higher than one which results in items being - skipped. If \var{stop} is not specified or is \code{None}, then iteration - continues indefinitely; otherwise, it stops at the specified position. - Unlike regular slicing, + skipped. If \var{stop} is \code{None}, then iteration continues until + the iterator is exhausted, if at all; otherwise, it stops at the specified + position. Unlike regular slicing, \function{islice()} does not support negative values for \var{start}, \var{stop}, or \var{step}. Can be used to extract related fields from data where the internal structure has been flattened (for @@ -208,13 +208,10 @@ by functions or loops that truncate the stream. \begin{verbatim} def islice(iterable, *args): - if args: - s = slice(*args) - next = s.start or 0 - stop = s.stop - step = s.step or 1 - else: - next, stop, step = 0, None, 1 + s = slice(*args) + next = s.start or 0 + stop = s.stop + step = s.step or 1 for cnt, element in enumerate(iterable): if cnt < next: continue |