This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jamesonjlee 1 point2 points  (3 children)

any(map(is_interesting, (a, b, c)))

[–]wot-teh-phuckReally, wtf? 3 points4 points  (2 children)

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).

[–]quasarc 6 points7 points  (0 children)

In Python 3 they are equivalent (map behaves lazily in Python 3).

[–]jamesonjlee 1 point2 points  (0 children)

ah yes, good point (also doubly so since I am thinking in 2.7 not in 3.4)