I have a function that attempts to read a value and returns False if there is a failure. Similar to this:
import random
def fun():
vals = [random.randint(0,3)]
try:
choice = vals[random.randint(0,1)]
except Exception as e:
logger.exception(e)
return False
return choice
This function is used by a test which behaves differently depending on the return value. When calling this function is using the 'is' keyword the only way to distinguish 0 from False?
test code...
if fun() is False:
do something...
if fun() == False:
what if fun returns 0 value
if not fun():
what if fun returns 0 value