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

Antoine Pitrou solipsis at pitrou.net
Thu Mar 6 10:52:12 CET 2014


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.

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.

Regards

Antoine.




More information about the Python-ideas mailing list