Hi Simon,

On 15 November 2016 at 11:44, Simon King <simon.k...@uni-jena.de> wrote:
> Hi Vincent,
>
> [...]
>
>> Python is using __nonzero__ to deal with these or/and/not operators.
>> This method __nonzero__ implicitly defines the conversion to booleans.
>> And Python sets
>>
>> x or y := x if bool(x) is True and y otherwise
>
> Is it not calling x.__or__(y), which could be overridden?

Indeed, __or__ is for the operator |. "or" can not be overridden.

sage: class a(object):
....:     def __or__(self, other):
....:         return "hello"
sage: a() or True
<__main__.a object at 0x7f2549683b50>
sage: a() | True
'hello'

Vincent

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

Reply via email to