Inverting a conditional function
I frequently have a function which tests some condition, returning True
or False, and want a function which reverses the condition.
If all I wanted was the result of calling the function, I could say
and be done with it, but I want a new function. I've been doing this:
lambda arg: not condition(arg)
which is okay, but its a bit long and adds the cost of an extra function
call. Is there a better way?
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson