In python, I am currently doing this:
if user_can_read(request.user, b) == False:
Is there any other way of checking if the function returns False?
You could just use
if user_can_read(request.user, b):
## do stuff
If user_can_read returns anything (except 0, False, etc), it will be considered True, and do stuff.
And the negation: if not user_can_read(request.user, b)
False. This is wrong, bool(-1) evaluates to True.False? That surprises me.-1 (since 0 is taken up by the first index).
if not function_return_boolean():if user_can_read(request.user,b) is False:booland nhahtdh's method if you specifically want to compare withFalseand not just any falsy value, sinceis Falseis nearly always a bug.