Evaluation of Truth Curiosity

Fredrik Lundh fredrik at pythonware.com
Thu Sep 21 05:30:16 EDT 2006


James Stroud wrote:

> I'm curious, in
> 
> py> 0 | (1 == 1)
> 1
> py> False | (1 == 1)
> True
> 
> What is the logic of the former expression not evaluating to True (or 
> why the latter not 1?)? Is there some logic that necessitates the first 
> operand's dictating the result of the evaluation? Or is this an artefact 
> of the CPython implementation?

looks like you're confusing binary or ("|") with logical or ("or").

binary or on booleans are only defined for boolean | boolean; for any 
other combination, the usual coercion rules apply.

</F>




More information about the Python-list mailing list