keyword 'in' not returning a bool?

Sion Arrowsmith siona at
Fri Feb 8 19:02:37 CET 2008

In article <mailman.521.1202490602.9267.python-list at>,
c james  <cjames at> wrote:
>>>> sample = {'t':True, 'f':False}
>>>> 't' in sample == True
>Why is this?

"Comparisons can be chained arbitrarily; for example, x < y <= z is
equivalent to x < y and y <= z, except that y is evaluated only once
[ ... ]
Two more operations with the same syntactic priority, "in" and "not
in", are supported only by sequence types"

't' in sample == True
is equivalent to:
't' in sample and sample == True
and obviously:
>>> sample == True

\S -- siona at --
   "Frankly I have no feelings towards penguins one way or the other"
        -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump

More information about the Python-list mailing list