get pairwise combinations of a list’s items in python
August 8th, 2011 by Lawrence David
use the itertools and random modules in python to get N pairwise combinations of a list’s items:
combo_it = itertools.combinations(my_list,2)
combo_l = list(combo_it)
random.shuffle(combo_l)
pair_l = combo_l[:N]