Just a style question: Is there a build-in method to get the combinations under the assertion of commutative property and excluding elements paired with itself?
you mean this?
a = ["1", "2", "3"] b = ["1", "2", "3"] print [(x,y) for x in a for y in b]
output:
[('1', '1'), ('1', '2'), ('1', '3'), ('2', '1'), ('2', '2'), ('2', '3'), ('3', '1'), ('3', '2'), ('3', '3')]