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

Ben Finney ben+python at benfinney.id.au
Wed Mar 5 23:16:06 CET 2014


"M.-A. Lemburg" <mal at egenix.com> writes:

> I don't know what all the fuzz is about. There are lots of types
> in Python that evaluate to False in certain corner cases, e.g.
> "", (), [], {}, 0, 0.0, 0j, None, etc.
>
> datetime.time(0,0,0) is just another one :-)

The salient difference is:

With the former set, they all embody concepts of either “empty” or “zero
magnitude”. They strongly connote “not there” within their domain of
values, hence map well to Boolean false.

With ‘datetime.time’ there is no equivalent: midnight is not special in
the way “empty” or “zero magnitude” are. Midnight is an arbitrary point
on a continuum, and is not a “not there” value. It should not be Boolean
false any more than any other time.

-- 
 \         “What is it that makes a complete stranger dive into an icy |
  `\   river to save a solid gold baby? Maybe we'll never know.” —Jack |
_o__)                                                           Handey |
Ben Finney



More information about the Python-ideas mailing list