c james 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? >
Precedence. In: 't' in sample == True sample == True is evaluated first then 't' in that which is false you should write ('t' in sample) == True but that is unnecessary because t' in sample is easier to read and to code and less prone to this problem. -Larry -- http://mail.python.org/mailman/listinfo/python-list