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

Shai Berger shai at platonix.com
Wed Mar 5 11:16:12 CET 2014

Hi all,

This is my first post here, following a recommendation from Alexander 
Belopolsky to use this list, to try to convince the Python developers to 
reopen a ticket. I am a long-time Python user, and a Django committer.

http://bugs.python.org/issue13936 is a complaint about the fact that midnight 
-- datetime.time(0,0,0) -- is evaluated as False in Boolean contexts. It was 
closed as invalid, under the claim that """It is odd, but really no odder than 
"zero values" of other types evaluating to false in Boolean contexts""".

I would like to ask for this to be reconsidered; since the ticket was closed, 
two main arguments were given for this:

1) The practical argument (paraphrasing Danilo Bergen and Andreas Pelme): The 
current semantics is surprising and useless; users do not expect valid times 
to be falsey, and do not normally want code to have special behavior on 
midnight. Users who ask for Boolean evaluation of a variable that's supposed 
to hold a time value, usually write "if var" as shorthand for "if var is not 

2) The principled argument (which I think is at the root of the practical 
argument); quoting myself from the ticket: """Midnight is not a "zero value", 
it is just a value. It does not have any special qualities analogous to those 
of 0, "", or the empty set. ... Midnight evaluting to false makes as much 
sense as date(1,1,1) -- the minimal valid date value -- evaluating to 


More information about the Python-ideas mailing list