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

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Mar 7 00:48:06 CET 2014


Terry Reedy wrote:
> What I find baffling and annoying is the endlessly 
> repeated false claim that there is nothing special about midnight,

I think what people are really saying is that it's not
special *enough* to be worth breaking people's intuition
about the truthiness of structured data types in Python.

Anyhow, it seems that the original motivation for the
current truthiness behaviour isn't really "midnight is
special", but rather "zero hours is special".

In other words, if you turn your head sideways and view
a time() object not as a time of day, but as a difference
between two times of day, then a time() representing
midnight morphs into a timedelta of zero hours, and it
kind of sort of makes sense to treat that as false.

If that's the intended interpretation of a time()
object, the docs do a poor job of conveying it. A
time() object is described as representing "a (local)
time of day", not "an amount of time since midnight".
The "local" even suggests that, if some midnight is to
special, it would be *local* midnight -- but this is
not the case for time() objects with a timezone.

It seems to me that those claiming "midnight is special"
are inventing a justification after the fact -- one
that is not supported by the actual behaviour.

Altogether, the whole thing seems to be a mess.

-- 
Greg


More information about the Python-ideas mailing list