summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-02-27 01:44:34 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-02-27 01:44:34 (GMT)
commitc105289ec4e22f5d53f3e5872ad6a49da8a33b6d (patch)
tree5a2507b6d4cea9703d55b931c94edf1ff67b1f4c /Doc
parent2ab0552b5e3a7ff33e777d6105632b2c1bcec59a (diff)
downloadcpython-c105289ec4e22f5d53f3e5872ad6a49da8a33b6d.zip
cpython-c105289ec4e22f5d53f3e5872ad6a49da8a33b6d.tar.gz
cpython-c105289ec4e22f5d53f3e5872ad6a49da8a33b6d.tar.bz2
Simply the sample code for combinations().
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/itertools.rst13
1 files changed, 6 insertions, 7 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index 6dc19a1..6155322 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -103,15 +103,14 @@ loops that truncate the stream.
yield tuple(pool[i] for i in vec)
while 1:
for i in reversed(range(r)):
- if vec[i] == i + n-r:
- continue
- vec[i] += 1
- for j in range(i+1, r):
- vec[j] = vec[j-1] + 1
- yield tuple(pool[i] for i in vec)
- break
+ if vec[i] != i + n - r:
+ break
else:
return
+ vec[i] += 1
+ for j in range(i+1, r):
+ vec[j] = vec[j-1] + 1
+ yield tuple(pool[i] for i in vec)
.. versionadded:: 2.6