On Nov 20, 3:48 am, Johannes Bauer <dfnsonfsdu...@ gmx.dewrote:
If you're using a version of Python before 2.6, you could also use a
list comprehension:
('a', 4)
('a', 9)
('a', 13)
('b', 4)
('b', 9)
('b', 13)
('c', 4)
('c', 9)
('c', 13)
a = { "a", "b", "c" }
b = { 4, 9, 13}
for (x, y) in someoperator(a, b):
print(x, y)
>
which would print all tuples of
"a", 4
"a", 9
"a", 13
"b", 4
"b", 9
"b", 13
"c", 4
"c", 9
"c", 13
b = { 4, 9, 13}
for (x, y) in someoperator(a, b):
print(x, y)
>
which would print all tuples of
"a", 4
"a", 9
"a", 13
"b", 4
"b", 9
"b", 13
"c", 4
"c", 9
"c", 13
list comprehension:
>>show = lambda *args: sys.stdout.writ e('%s\n' % args)
>>[show((x,y)) for x in a for y in b]
>>[show((x,y)) for x in a for y in b]
('a', 9)
('a', 13)
('b', 4)
('b', 9)
('b', 13)
('c', 4)
('c', 9)
('c', 13)