Really confused by the difference in behavior between the two following scripts
test.py
while True:
print 'Enter commands, blah blah'
input = raw_input(">> ") #get keyboard input
if (input == 'string'):
print '\n' #whatever task
elif (input == 'quit'):
exit() #exits the application
else:
print 'Invalid'
test2.py
while True:
print 'Enter commands, blah blah'
input = raw_input(">> ") #get keyboard input
if (input == 'string'):
print '\n' #whatever task
elif (input == 'quit' or 'exit'):
exit() #exits the application
else:
print 'Invalid'
Here's the result if you run both of these scripts
bred@loaf:~/py$ python test.py
Enter commands, blah blah
>> a
Invalid
Enter commands, blah blah
>> quit
bred@loaf:~/py$ python test2.py
Enter commands, blah blah
>> a
bred@loaf:~/py$
As you can see, test.py works as expected, but test2.py exits immediately rather than performing the else statement. Very confused, the only difference between the two scripts is the "or 'exit'" in the elif statement.