Created
September 12, 2009 02:16
-
-
Save srid/185695 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def original(): | |
for i in range(10): | |
for j in range(10): | |
for k in range(10): | |
if i == j and j == k: | |
yield "All equal" | |
elif (i == j and j != k) or (i == k and j != k): | |
yield "2 equal" | |
else: | |
yield "None equal" | |
def original2(): | |
return ["All equal" if i==j and j==k else ( | |
"2 equal" if (i==j and j!=k) or (i==k and j!=k) \ | |
else "None equal") | |
for i in range(10) | |
for j in range(10) | |
for k in range(10)] | |
assert tuple(original()) == tuple(original2()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment