weird behaviour of "0 in [] is False"

Paul Robson autismuk at autismuk.muralichucks.freeserve.co.uk
Tue Nov 30 15:33:25 EST 2004


John Roth wrote:

> It's not an error. As one of the first responders said, check
> the language definition. That defines both 'in' and 'is'
> as equality operators, and defines exactly what a chain
> of equality operators means.
> 
> In this case, it means:
> 
> (0 in l) and (l is False)
> 
> The and short circuits, giving the result of False without
> ever doing the final comparison.
> 
> Granted, that's not exactly obvious...

Thanks ; you learn something every day :)




More information about the Python-list mailing list