[Tutor] trouble with function-- trying to check differences btwn 2 strings

David Perlman dperlman at wisc.edu
Wed Mar 7 00:41:53 CET 2007


I think it's a little strange and possibly problematic that type(1)  
is 'int' and type(True) is 'bool' but
1 == True
specifically evaluates to True even though anything else, even if it  
evaluates to True when cast as a boolean, is not == True.

 >>> 1 == True
True
 >>> 2 == True
False
 >>> 0 == False
True
 >>> 2 == False
False

I guess I just need to remember to always look on the bright side of  
life.

On Mar 6, 2007, at 4:44 PM, John Fouhy wrote:

> 'foo == bar in baz' should group as '(foo == bar) in baz'.  But Luke's
> example contradicts this:
>
>>>> lst = [1,2,3,4]
>>>> 555 == 555 in lst
> False
>>>> (555 == 555) in lst
> True
>>>> 1 == 1 in lst
> True
>
> (this works because 1 == True)

--
-dave----------------------------------------------------------------
Science arose from poetry... when times change the two can meet again
on a higher level as friends. -Göthe




More information about the Tutor mailing list