Re: How is the logical processing being done for strings like 'Dog' and 'Cat'

2008-10-20 Thread Tim Roberts
Sumitava Mukherjee <[EMAIL PROTECTED]> wrote: >Hi all, >I am a novice programmer in Python. >Please could you explain me the results (regarding logical operators). > >I get this: > print bool('God' and 'Devil') >True > >[This is ok because (any) string is True, so; (True and True) gives >True

Re: How is the logical processing being done for strings like 'Dog' and 'Cat'

2008-10-20 Thread Steven D'Aprano
On Mon, 20 Oct 2008 18:41:23 -0700, Sumitava Mukherjee wrote: > What is python doing when we type in ('God' and 'Devil') or key in (01 > and 10) ? There are two important things you need to know: (1) All Python objects have a boolean context. (2) Python's boolean operators are short-circuit op

Re: How is the logical processing being done for strings like 'Dog' and 'Cat'

2008-10-20 Thread zaarg
On Oct 20, 9:41 pm, Sumitava Mukherjee <[EMAIL PROTECTED]> wrote: > Hi all, > I am a novice programmer in Python. > Please could you explain me the results (regarding logical operators). > > I get this: > > >>> print bool('God' and 'Devil') > > True > > [This is ok because (any) string is True, Not

Re: How is the logical processing being done for strings like 'Dog' and 'Cat'

2008-10-20 Thread Benjamin
On Oct 20, 8:41 pm, Sumitava Mukherjee <[EMAIL PROTECTED]> wrote: > Hi all, > I am a novice programmer in Python. > Please could you explain me the results (regarding logical operators). > > I get this: > > >>> print bool('God' and 'Devil') > > True > > [This is ok because (any) string is True, so;

How is the logical processing being done for strings like 'Dog' and 'Cat'

2008-10-20 Thread Sumitava Mukherjee
Hi all, I am a novice programmer in Python. Please could you explain me the results (regarding logical operators). I get this: >>> print bool('God' and 'Devil') True [This is ok because (any) string is True, so; (True and True) gives True] >>> print('God' and 'Devil') Devil [This is what I d