def func():
print 'no early termination'
return 0
if __name__ == "__main__":
if 1 or func():
print 'finished'
The output:
finished
since the "1 or func()" terminates early without calling the func() because "1 or something" is always true. However, when switching to bitwise operator:
def func():
print 'no early termination'
return 0
if __name__ == "__main__":
if 1 | func():
print 'finished'
I get the output:
no early termination
finished
Why is that? this doesn't seem very efficient