Python one-liner that answers: Do any of these inputs return True for this function?
Question: Goal: Is there a built-in Python function (or one-liner) which will submit
arguments to a function, but only until the function returns `True` for the
first time? I would like to be able to answer the question

> "Do _any_ of these inputs return `True` for this function?"

I don't particularly care about the results of the function when using those
inputs.

The [`any`](https://docs.python.org/2/library/functions.html#any) function
returns `True` if any of the `iterable` items passed is `True`. The
[`map`](https://docs.python.org/2/library/functions.html#map) function applies
arguments to a function and returns the results of all of those function
calls.

So I'm looking for something in between the two. `any` only applies to
`iterable` so is not relevant to functions (unless I want to `map` all
arguments to the function); and `map` isn't exactly what I want because it
executes the function on all inputs.


Answer: [`any`](https://docs.python.org/2/library/functions.html#any) is "lazy", so
will `return` as soon as the first element of `iterable` evaluates to `True`.
However, in Python 2.x *, `map` builds a list of the results, applying
`function` to everything in `iterable` before returning.

There is an alternative, though:
[`itertools.imap`](https://docs.python.org/2/library/itertools.html#itertools.imap),
which returns an iterator instead of a list, restoring lazy evaluation. Once
you:

    
    
    from itertools import imap
    

Your one-liner is:

    
    
    any(imap(function, iterable))
    

* _Note that`map` already returns an iterator [in Python 3.x](https://docs.python.org/3.4/library/functions.html#map), and therefore `itertools.imap` is no longer available._

