from itertools import permutations #from http://www.sharejs.com print(list(permutations([1, 2, 3])))