Created
July 29, 2011 02:48
-
-
Save ddbeck/1113035 to your computer and use it in GitHub Desktop.
Generator Madness
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
# you'll do something silly like this | |
def v1_powers_of_two(limit=10): | |
def po2s(): | |
for x in range(0, limit): | |
yield 2 ** x | |
return list(po2s()) | |
# instead of something sensible like this | |
def v2_powers_of_two(limit=10): | |
p2s = [] | |
for x in range(0, limit): | |
p2s.append(2 ** x) | |
return p2s | |
print v1_powers_of_two() | |
print v2_powers_of_two() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment