def inner_product(iterable):
    """the product of an iterable with itself"""
return itertools.product(iterable, repeat=2)

def same(pair):
    """does this pair contain two of the same thing?"""
return operator.is_(*pair)
universe = 'abcd'
pairs = inner_product(universe)
unique_pairs = itertools.filterfalse(same, pairs)
for pair in unique_pairs:
    print(pair)
"""
('a', 'b')
('a', 'c')
('a', 'd')
('b', 'a')
('b', 'c')
('b', 'd')
('c', 'a')
('c', 'b')
('c', 'd')
('d', 'a')
('d', 'b')
('d', 'c')
"""
Уродливая комбинация выражения генератора с циклом for