>
>
>
> This is inconsistent (and documented ;-). 


But is it documented someplace easy for Sage users to find?  Thanks!

 

> For the operations "or" and 
> "and" Python actually uses "__nonzero__". *Not* "__or__" and "__and__" 
> which are the bitwise operation "|" and "&". 
>
> They work as follows: 
>
> In "x and y" if "x.__nonzero__()" is False then the result is "x" 
> otherwise it is "y". 
>
> In "x or y" if "x.__nonzero__()" is True then the result is "x" and 
> otherwise it is "y". 
>
> Examples: 
>
> sage: 5 and 4 and 19 
> 19 
> sage: 4 and 0 and 12 
> 0 
> sage: 0 or 7 
> 7 
>
> Similarly, even if X and Y are not defined you can write 
>
> sage: False and X and Y 
> False 
>
> The only way to fix Unknown would be to patch (non trivially) Python. 
> Boolean inherits from int... and it would be hard to have a third party 
> "Unknown" coherent with this inheritance. There was a slightly related 
> proposal, PEP 335, which was rejected with good reasons. We could 
> propose a new PEP for trooleans but it is not clear what should be the 
> concrete implementation. 
>
> Vincent 
>
> On 25/11/15 01:56, kcrisman wrote: 
> > On social media: 
> > 
> > sage: False or Unknown 
> > Unknown 
> > sage: Unknown or False 
> > False 
> > sage: False and Unknown 
> > False 
> > sage: Unknown and False 
> > Unknown 
> > 
> > It does seems somewhat inconsistent... 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to