I want something like code below, but \"pythonic\" style or using standard library:
def combinations(a,b):
for i in a:
for j in b:
y
As @Sven said, your code is attempting to get all ordered pairs of elements of the lists a and b. In this case itertools.product(a,b) is what you want. If instead you actually want "combinations", which are all unordered pairs of distinct elements of the list a, then you want itertools.combinations(a,2).
>>> for pair in itertools.combinations([1,2,3,4],2):
... print pair
...
(1, 2)
(1, 3)
(1, 4)
(2, 3)
(2, 4)
(3, 4)