[Baypiggies] What is happening here with true/false comparisons

Ryan Delucchi bender at onsrc.com
Mon Jan 25 22:25:46 CET 2010


This appears to be an order of precedence issue.

Observe:

 >>> (a in alist) == (b in alist)
True

Ryan

On Jan 25, 2010, at 1:12 PM, Max Slimmer wrote:

> Can anyone explain the following:
>
> >>> a = 1
> >>> b = 2
> >>> alist = [5,6]
> >>> print a in alist
> False
>
> >>> a in alist == b in alist
> False
> >>> a in alist == a in alist
> False
> >>> bool(a in alist) == bool(b in alist)      # this does what we  
> expect
> True
> >>> c = 5
> >>> c in alist == c in alist
> False
> >>>
>
> max
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies



More information about the Baypiggies mailing list