I have two functions that return a bool. The first is using bool()
and the second is using is not None
.
def func_1(x) -> bool:
return bool(x)
def func_2(x) -> bool:
return x is not None
foo = "something"
bar = None
print(func_1(foo))
print(func_2(foo))
print("-----")
print(func_1(bar))
print(func_2(bar))
Here is the output
True
True
-----
False
False
Is there a difference between is not None
and bool()
in this instance? Is there something I may want to consider when using one or the other?