9.5 Generating all combinations
The itertools module also supports computing all combinations of a set of values. When looking at combinations, the order doesn’t matter, so there are far fewer combinations than permutations. The number of combinations is often stated as  =
 =  . This is the number of ways that we can take combinations of r things at a time from a universe of p items overall.
. This is the number of ways that we can take combinations of r things at a time from a universe of p items overall.
For example, there are 2,598,960 five-card poker hands. We can actually enumerate all 2 million hands by executing the following command:
>>> from itertools import combinations, product 
 
>>> hands = list( 
...     combinations( 
...         tuple( 
...             product(range(13), ’♠♡♢♣’) 
...         ), 5 
...     ) ... 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                