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

Stefan Krah stefan at bytereef.org
Thu Mar 6 12:13:36 CET 2014


Antoine Pitrou <solipsis at ...> writes:
> Le 06/03/2014 09:35, M.-A. Lemburg a écrit :
> > Just in case you're looking for a relevant use case:
> >
> > Having bool(time(0,0,0)) allows you to quickly check whether you are
> > dealing with a datetime value with (non-trivial) time part or not.
> 
> This sounds like the kind of shortcut that only an expert would know to 
> take, not something that's actually a good design decision.
> It's as though pathlib.Path('') evaluated to false for some obscure use 
> case that I cared about.

On the other hand I would not dare to assume it's True without
checking.


> It is not a coincidence, IMO, that the three persons arguing that the 
> current behaviour is reasonable are implementors of datetime modules: 
> you, Tim and Alexander. All other people find the behaviour baffling.

Not all. :)  I think viewing midnight as (unix_time % 86400) is
quite reasonable.


Stefan Krah 




More information about the Python-ideas mailing list