First page Back Continue Last page Overview Image
Combinatoric Generators
- product(iterable, q, ... [repeat=1]) --> cartesian product
e.g. product(A, B) returns the same as:
(x,y) for x in A for y in B)
- permutations(iterable[, r])
Return successive r-length permutations of elements in the iterable.
permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
- combinations(iterable, r)
Return successive r-length combinations of elements in the iterable.
combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
- combinations_with_replacement(iterable, r)
like combinations but with replacements