>>> import itertools >>> list(itertools.permutations(range(3), 2)) [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]