Permutations and Combinations
itertools
import itertools
# Four adjacent directions
[[dx, dy] for dx, dy in itertools.permutations([-1, 0, 1], 2) if abs(dx) != abs(dy)]
import itertools
# Four adjacent directions
[[dx, dy] for dx, dy in itertools.permutations([-1, 0, 1], 2) if abs(dx) != abs(dy)]