I have a boolean variable named mapped_filter.
If I am not wrong, this variable can hold 3 values, either True, False or None.
I want to differentiate each of the 3 possible values in an if statement. Is there a better way to achieve that than doing the following?
if mapped_filter:
print("True")
elif mapped_filter == False:
print("False")
else:
print("None")
if mapped_filter is Noneunmistakably compares withNone...casestatement, I'm sorry, but no, there's not a better way. You still can do crazy things like having a dictionary likecrazy_dict = {True: ..., False:..., None: ...}and thencrazy_dict[mapped_filter]().mapped_filteris a boolean, it can only have two different values:TrueorFalse.