I have a section in my code at the end of a recursive call that is as follows:
if (condition):
# Some code here
else:
return function_call(some_parameters) or function_call(some_parameters)
and it may evaluate to
return None or 0
where it will return 0 (an integer, as expected) or
return 0 or None
where it will return None (expected 0)
My question is, is it possible to have Python to return 0 (as an INTEGER) in the case immediately above?
Here is some code representing the scenario
$ cat test.py
#!/usr/bin/python3
def test_return():
return 0 or None
def test_return2():
return None or 0
def test_return3():
return '0' or None #Equivalent of `return str(0) or None`
print( test_return() )
print( test_return2() )
print( test_return3() )
$ ./test.py
None
0
0
Note: 0 should be returned as an integer.