True is True / False is False?
Tim Chase
python.list at tim.thechases.com
Wed Jul 22 14:54:39 EDT 2020
On 2020-07-22 11:54, Oscar Benjamin wrote:
>> On Wed, Jul 22, 2020 at 11:04 AM Tim Chase wrote:
>>> reading through the language specs and didn't encounter
>>> anything about booleans returned from comparisons-operators,
>>> guaranteeing that they always return The One True and The One
>>> False.
>>
>> That said, though, a comparison isn't required to return a bool.
>> If it *does* return a bool, it has to be one of those exact two,
>> but it could return anything it chooses. But for built-in types
>> and most user-defined types, you will indeed get a bool.
>
> I'm not sure if this is relevant to the question but thought I'd
> mention concrete examples. A numpy array will return non-bool for
> both of the mentioned operators
that is indeed a helpful data-point. Do you know of any similar
example in the standard library of things where comparison-operators
return something other than True or False (or None)?
Thanks,
-tkc
More information about the Python-list
mailing list