keyword 'in' not returning a bool?

Patrick Dwyer siliconredox at gmail.com
Fri Feb 8 12:17:43 EST 2008


'in' has a lower operator precedence than '=='

('t' in sample) == True

would fix the operator precedence.

On Feb 8, 2008 11:09 AM, c james <cjames at callone.net> wrote:

> Try this
>
> >>> sample = {'t':True, 'f':False}
> >>> 't' in sample
> True
> >>> type('t' in sample)
> <type 'bool'>
> >>> 't' in sample == True
> False
>
> Why is this?  Now try
> >>> bool('t' in sample) == True
> True
>
> Can someone explain what is going on?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080208/01a0de7f/attachment-0001.html>


More information about the Python-list mailing list