answered 6 years ago
You can use product provided by the itertools Python module:
product
itertools
sage: list(product([0,1,2], repeat=2)) [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]