From cac8f7829f90c809c9687f7446252af13b95a8b6 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Tue, 28 Jul 2009 04:05:28 -0400 Subject: [PATCH] typos --- advanced-iterators.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced-iterators.html b/advanced-iterators.html index 924e6e9..1d68866 100755 --- a/advanced-iterators.html +++ b/advanced-iterators.html @@ -253,8 +253,8 @@ gen = ord_map(unique_characters) File "<stdin>", line 1, in StopIteration
    -
  1. The itertools module has all kinds of fun stuff in it, including a permutations() function that does all the hard work of finding permutations. -
  2. The permutations() function takes a sequence (here a list of three integers) and a number, which is the number of items you want in each smaller group. The function returns an iterator, which you can use in a foor loop or any old place that iterates. Here I’ll step through the iterator manually to show all the values. +
  3. The itertools module has all kinds of fun stuff in it, including a permutations() function that does all the hard work of finding permutations. +
  4. The permutations() function takes a sequence (here a list of three integers) and a number, which is the number of items you want in each smaller group. The function returns an iterator, which you can use in a for loop or any old place that iterates. Here I’ll step through the iterator manually to show all the values.
  5. The first permutation of [1, 2, 3] taken 2 at a time is (1, 2).
  6. Note that permutations are ordered: (2, 1) is different than (1, 2).
  7. That’s it! Those are all the permutations of [1, 2, 3] taken 2 at a time. Pairs like (1, 1) and (2, 2) never show up, because they contain repeats so they aren’t valid permutations. When there are no more permutations, the iterator raises a StopIteration exception.