This is my implementation:
def walk_two(a, b):
for x in a:
for y in b:
yield x, y
a = xrange(2)
b = xrange(3)
for x, y in walk_two(a, b):
print x, y
With this output:
0 0
0 1
0 2
1 0
1 1
1 2
Is there a better (more pythonic) way of doing that? A built-in? A more generic walkN?