xor operator
Dom Grigonis
dom.grigonis at gmail.com
Mon Nov 13 12:47:50 EST 2023
Well yes, I don’t think naming is very accurate. If iterable has 2 elements, then it is `xor`, otherwise it is something else - it checks the number of truth values in iterable.
Short circuiting happens, when:
xor([True, True, False, False], n=1)
At index 1 it is clear that the answer is false.
Regards,
DG
> On 13 Nov 2023, at 19:42, Barry <barry at barrys-emacs.org> wrote:
>
>
>
>> On 13 Nov 2023, at 15:16, Dom Grigonis via Python-list <python-list at python.org> wrote:
>>
>> I think it could be useful to have `xor` builtin, which has API similar to the one of `any` and `all`.
>
> I do not understand how xor(iterator) works.
> I thought xor takes exactly 2 args.
>
> I also do not understand how xor can be short circuited.
> For AND or OR only looking at the first arg works.
> But that does not work for xor right?
>
> Barry
>
>
More information about the Python-list
mailing list