[Python-ideas] Please reconsider the Boolean evaluation of midnight

Oscar Benjamin oscar.j.benjamin at gmail.com
Wed Mar 5 13:34:09 CET 2014


On 5 March 2014 10:59, Shai Berger <shai at platonix.com> wrote:
> On Wednesday 05 March 2014 12:44:07 Paul Moore wrote:
>>
>> I actually find the idea of truth-testing a value that's expected to
>> have a type that is always true *more* unintuitive than an explicit
>> "is not None", so I'd fix the above code regardless of what the truth
>> value of midnight is.
>
> I can appreciate this point of view, but I think it is not the position
> generally taken by Python (if it were, Boolean evaluation of an object of a
> type that is always true would have raised an exception).

I think it's clear that if this were new code being added to the
stdlib then the consensus would be that having midnight evaluate as
False is ridiculous.

The question is surely whether the issue is worth a backwards
compatibility break not whether the current behaviour is a good idea
(it clearly isn't).


Oscar


More information about the Python-ideas mailing list