Created
November 14, 2012 00:33
-
-
Save jeamland/4069388 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
import itertools | |
def is_odd(val): | |
print "Checking", str(val) | |
return bool(val % 2) | |
print "Using map..." | |
print any(map(is_odd, range(0, 10))) | |
print "\nUsing itertools.imap..." | |
print any(itertools.imap(is_odd, range(0, 10))) | |
print "\nUsing generator expression..." | |
print any(is_odd(foo) for foo in range(0, 10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment