The Python standard library defines an any() function that
Return True if any element of the iterable is true. If the iterable is empty, return False.
You can use a combination of any
and map
if you really want to keep your lambda notation like so :
any(map(lambda e: isinstance(e, int) and e > 0, [1, 2, 'joe']))
But it is better to use a generator expression because it will not build the whole list twice.
How about:
>>> any(isinstance(e, int) and e > 0 for e in [1,2,'joe'])
True
It also works with all()
of course:
>>> all(isinstance(e, int) and e > 0 for e in [1,2,'joe'])
False