Pythonの条件演算子と遅延評価を見比べる

条件演算子

m = 10
for i in range(m):
    print i, "odd" if i%2 else "even"
==
0 even
1 odd
2 even
3 odd
4 even
5 odd
6 even
7 odd
8 even
9 odd

遅延評価

m = 10
for i in range(m):
    print i, i%2 and "odd" or "even"
==
0 even
1 odd
2 even
3 odd
4 even
5 odd
6 even
7 odd
8 even
9 odd