Created
January 14, 2013 16:49
-
-
Save cshoe/4531451 to your computer and use it in GitHub Desktop.
Proving that Python only evaluates to the first `True` value in an or statement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def first_function(return_value): | |
"""Returns `return_value`. | |
""" | |
print 'Running FIRST function' | |
return return_value | |
def second_function(return_value): | |
"""Returns `return_value`. | |
""" | |
print 'Running SECOND function' | |
return return_value | |
def third_function(return_value): | |
"""Returns `return_value`. | |
""" | |
print 'Running THIRD function' | |
return return_value | |
def main(): | |
if first_function(True) or second_function(False): | |
print 'first clause is True' | |
if first_function(False) or second_function(True) or third_function(True): | |
print 'second clause is True' | |
if first_function(False) or second_function(False) or third_function(True): | |
print 'third clause is True' | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment