Re: Error in or

2015-06-12 Thread Marko Rauhamaa
Steven D'Aprano :

> This is better written as:
>
> if any(substr in inp1 for substr in 
>['AND', 'OR', 'NOT', '>', '&', 'MAYBE', '(', '*', ' " ']):
> print 'FINE'

Or, equivalently:

   for substr in ['AND', 'OR', 'NOT', '>', '&', 'MAYBE', '(', '*', ' " ']:
   if substr in inp1:
   print('FINE')
   break


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error in or

2015-06-12 Thread Steven D'Aprano
On Thu, 11 Jun 2015 08:40:50 -0700, subhabrata.banerji wrote:

>   if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in
>   inp1) or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*"
>   in inp1) or (''' " ''' in   inp1):

This is better written as:

if any(substr in inp1 for substr in 
   ['AND', 'OR', 'NOT', '>', '&', 'MAYBE', '(', '*', ' " ']):
print 'FINE'


-- 
Steve
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error in or

2015-06-11 Thread Mark Lawrence

On 11/06/2015 17:39, subhabrata.bane...@gmail.com wrote:

On Thursday, June 11, 2015 at 9:20:59 PM UTC+5:30, Ian wrote:

On Thu, Jun 11, 2015 at 9:40 AM,

   if write this it is working fine, but if I write

   if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) or ("&" in inp1) or ("MAYBE" 
in inp1) or ("(" in inp1) or ("*" in inp1) or (''' " ''' in   inp1):

  the portion of (''' " ''' in   inp1) is not working.


Not working how? I copy-pasted the line and it appears to work fine.


Dear Sir,
Thank you for your kind reply. Nice to know your reply, but I am trying to send 
you my experiment, please see my results,


def input1(n):

inp1=raw_input("PRINT YOUR QUERY:")
if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) or ("&" in inp1) or 
("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) or (''' " ''' in   inp1):
print "FINE"



input1(1)

PRINT YOUR QUERY:"Java"

input1(1)

PRINT YOUR QUERY:"Obama in London"

input1(1)

PRINT YOUR QUERY:Obama AND Bush
FINE

input1(1)

PRINT YOUR QUERY:Obama OR Bush
FINE




you may get better my problem.

Regards,
Subhabrata Banerjee.



In [6]: input1(1)
PRINT YOUR QUERY:Bush ANDES Obama
FINE

In [8]: input1(1)
PRINT YOUR QUERY:Bush ORDER Obama
FINE

Do you actually want this?

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: Error in or

2015-06-11 Thread subhabrata . banerji
On Thursday, June 11, 2015 at 10:18:33 PM UTC+5:30, Ian wrote:
> On Thu, Jun 11, 2015 at 10:39 AM,   wrote:
> > On Thursday, June 11, 2015 at 9:20:59 PM UTC+5:30, Ian wrote:
> >> On Thu, Jun 11, 2015 at 9:40 AM,
> >> >   if write this it is working fine, but if I write
> >> >
> >> >   if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in 
> >> > inp1) or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in 
> >> > inp1) or (''' " ''' in   inp1):
> >> >
> >> >  the portion of (''' " ''' in   inp1) is not working.
> >>
> >> Not working how? I copy-pasted the line and it appears to work fine.
> >
> > Dear Sir,
> > Thank you for your kind reply. Nice to know your reply, but I am trying to 
> > send you my experiment, please see my results,
> >
>  def input1(n):
> > inp1=raw_input("PRINT YOUR QUERY:")
> > if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in 
> > inp1) or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in 
> > inp1) or (''' " ''' in   inp1):
> > print "FINE"
> >
> >
>  input1(1)
> > PRINT YOUR QUERY:"Java"
>  input1(1)
> > PRINT YOUR QUERY:"Obama in London"
>  input1(1)
> > PRINT YOUR QUERY:Obama AND Bush
> > FINE
>  input1(1)
> > PRINT YOUR QUERY:Obama OR Bush
> > FINE
> 
> >
> > you may get better my problem.
> 
> The substring that you're looking for has spaces around the " symbol.
> The example inputs that you gave don't have spaces around the "
> symbols, so they don't contain the substring.  The triple quotes are
> also unnecessary, though harmless -- it's not a multiline string, and
> there are no ' symbols to escape in the string. Try replacing the
> substring with just this: '"'.

Dear Sir,
Thank you. It seems working.
Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error in or

2015-06-11 Thread Ian Kelly
On Thu, Jun 11, 2015 at 10:39 AM,   wrote:
> On Thursday, June 11, 2015 at 9:20:59 PM UTC+5:30, Ian wrote:
>> On Thu, Jun 11, 2015 at 9:40 AM,
>> >   if write this it is working fine, but if I write
>> >
>> >   if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) 
>> > or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) or 
>> > (''' " ''' in   inp1):
>> >
>> >  the portion of (''' " ''' in   inp1) is not working.
>>
>> Not working how? I copy-pasted the line and it appears to work fine.
>
> Dear Sir,
> Thank you for your kind reply. Nice to know your reply, but I am trying to 
> send you my experiment, please see my results,
>
 def input1(n):
> inp1=raw_input("PRINT YOUR QUERY:")
> if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in 
> inp1) or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) 
> or (''' " ''' in   inp1):
> print "FINE"
>
>
 input1(1)
> PRINT YOUR QUERY:"Java"
 input1(1)
> PRINT YOUR QUERY:"Obama in London"
 input1(1)
> PRINT YOUR QUERY:Obama AND Bush
> FINE
 input1(1)
> PRINT YOUR QUERY:Obama OR Bush
> FINE

>
> you may get better my problem.

The substring that you're looking for has spaces around the " symbol.
The example inputs that you gave don't have spaces around the "
symbols, so they don't contain the substring.  The triple quotes are
also unnecessary, though harmless -- it's not a multiline string, and
there are no ' symbols to escape in the string. Try replacing the
substring with just this: '"'.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error in or

2015-06-11 Thread subhabrata . banerji
On Thursday, June 11, 2015 at 9:20:59 PM UTC+5:30, Ian wrote:
> On Thu, Jun 11, 2015 at 9:40 AM,  
> >   if write this it is working fine, but if I write
> >
> >   if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) 
> > or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) or 
> > (''' " ''' in   inp1):
> >
> >  the portion of (''' " ''' in   inp1) is not working.
> 
> Not working how? I copy-pasted the line and it appears to work fine.

Dear Sir,
Thank you for your kind reply. Nice to know your reply, but I am trying to send 
you my experiment, please see my results,

>>> def input1(n):
inp1=raw_input("PRINT YOUR QUERY:")
if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in 
inp1) or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) 
or (''' " ''' in   inp1):
print "FINE"


>>> input1(1)
PRINT YOUR QUERY:"Java"
>>> input1(1)
PRINT YOUR QUERY:"Obama in London"
>>> input1(1)
PRINT YOUR QUERY:Obama AND Bush
FINE
>>> input1(1)
PRINT YOUR QUERY:Obama OR Bush
FINE
>>> 

you may get better my problem. 

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error in or

2015-06-11 Thread Ian Kelly
On Thu, Jun 11, 2015 at 9:40 AM,   wrote:
>   if write this it is working fine, but if I write
>
>   if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) or 
> ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) or (''' 
> " ''' in   inp1):
>
>  the portion of (''' " ''' in   inp1) is not working.

Not working how? I copy-pasted the line and it appears to work fine.
-- 
https://mail.python.org/mailman/listinfo/python-list


Error in or

2015-06-11 Thread subhabrata . banerji
Dear Group,

In the following script,

  inp1=raw_input("PRINT YOUR INPUT:")
  if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) or 
("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1):
  
  if write this it is working fine, but if I write 
   
  if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) or 
("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) or (''' " 
''' in   inp1):
  
 the portion of (''' " ''' in   inp1) is not working.

If any one of the esteemed members may kindly suggest the error I am making.

I am using Python2.7+ on Windows 7 Professional. 

Apology for any indentation error. 

Regards,
Subhabrata Banerjee. 
 
-- 
https://mail.python.org/mailman/listinfo/python-list