I try to define a function as short as possible, and the function to return True if test is always true, and false if there is some value for which it is false. I tried so:
def res(v): for d in List: return True if v.test(d) else: pass
It does not work. How to define such a function ?
I want to define it on only one line.
What about:
Or
As mentionned by Vladimir in the comments, your
testis actually a method of an object calledv, so it should actually be:You probably would like to pass the
Listas an argument too though.Have a look at the documentation for the
allmethod, the one for themapmethod andlambdafunctions.