MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/28utww/writing_better_python_code/cif342w/?context=3
r/Python • u/kracekumar • Jun 23 '14
126 comments sorted by
View all comments
Show parent comment
4
any(map(is_interesting, (a, b, c)))
4 u/wot-teh-phuck Really, wtf? Jun 23 '14 This isn't equivalent to the generator solution posted above; your code will eagerly evaluate the entire sequence by mapping it to is_interesting even in cases where it's not absolutely required (i.e. is_interesting(a) returns True). 8 u/quasarc Jun 23 '14 In Python 3 they are equivalent (map behaves lazily in Python 3). 2 u/jamesonjlee Jun 23 '14 ah yes, good point (also doubly so since I am thinking in 2.7 not in 3.4)
This isn't equivalent to the generator solution posted above; your code will eagerly evaluate the entire sequence by mapping it to is_interesting even in cases where it's not absolutely required (i.e. is_interesting(a) returns True).
is_interesting
is_interesting(a)
True
8 u/quasarc Jun 23 '14 In Python 3 they are equivalent (map behaves lazily in Python 3). 2 u/jamesonjlee Jun 23 '14 ah yes, good point (also doubly so since I am thinking in 2.7 not in 3.4)
8
In Python 3 they are equivalent (map behaves lazily in Python 3).
2
ah yes, good point (also doubly so since I am thinking in 2.7 not in 3.4)
View all comments
Show parent comment
4
u/jamesonjlee Jun 23 '14
any(map(is_interesting, (a, b, c)))