Boolean Operator Confusion

Albert van der Horst albert at spenarnc.xs4all.nl
Fri May 8 05:14:50 EDT 2015


In article <553a5ded$0$12978$c3e8da3$5496439d at news.astraweb.com>,
Steven D'Aprano  <steve+comp.lang.python at pearwood.info> wrote:
>On Sat, 25 Apr 2015 12:50 am, subhabrata.banerji at gmail.com wrote:
>
>> Dear Group,
>>
>> I am trying to understand the use of Boolean operator in Python. I am
>> trying to write small piece of script, as follows,
>>
>> def input_test():
>>     str1=raw_input("PRINT QUERY:")
>>     if "AND" or "OR" or "NOT" in str1:
>>         print "It is a Boolean Query"
>>     elif "AND" or "OR" or "NOT" not in str1:
>>         print "It is not a Boolean Query"
>>     else:
>>         print "None"
>
>First problem: why do you sometimes return "None"? You have two possible
>answers: either something is a boolean query, or it is not. There is no
>third choice. ("It's a boolean query, but only on Wednesdays.")

In the context of testcode where the OP is not knowing what is going on
it is absolutely useful, and legit. His problem is that it is Wednesday and
weird things happen.


>Steven
>
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst




More information about the Python-list mailing list