Skip to Content
Secret Recipes of the Python Ninja
book

Secret Recipes of the Python Ninja

by Cody Jackson
May 2018
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 37m
English
Packt Publishing
Content preview from Secret Recipes of the Python Ninja

Combinatoric iterators

Combinatoric iterators are concerned with the enumeration, combination, and permutation of element sets:

  1. The product(*iterables, repeat=1) iterator produces a Cartesian product from the inputted iterable objects; it is essentially the same as using nested for loops in a generator. The nested loops cycle through the input iterables, with the rightmost element incrementing every iteration. The pattern returned is dependent upon the input; that is, if the input iterables are sorted, the output product tuples will be sorted as well.

It is important to point out that Cartesian products are not mathematical products; that is, they aren't the result of multiplication. They are actually part of analytic geometry and are all ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Expanding World of Python

The Expanding World of Python

Dane Hillard

Publisher Resources

ISBN: 9781788294874Supplemental Content