[Python-ideas] bool(datetime.time(0, 0))

Jim Jewett jimjjewett at gmail.com
Wed May 9 02:53:58 CEST 2012


On Mon, May 7, 2012 at 12:06 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:

> Why do you want to reproduce it? Does midnight warrant any special
> shortcut for testing? Especially one that is confusing to many
> readers.

Why do you think that 0 represents midnight?   *Because* it is zero,
it will often be used as a default for missing data.

Python at least offers alternatives, but that doesn't mean people will
use them, and certainly doesn't mean that the data wasn't already
corrupted before python ever saw it.  And if I know the hour but not
the minute or second, I myself would generally use zeros for the
missing data even in python.

Saying that it represents midnight because it is defined that way is
true only in the same sense that evaluating to False is correct
because it is defined that way.

With a sufficiently powerful time machine, I would use 1-60 to
represent the minute/second being traversed and leave 0 for missing
data.  (And making this the right answer would probably involve going
back long before python considered the issue.)

Without such a time machine, none of options are good enough to
justify breaking backwards compatibility.

-jJ



More information about the Python-ideas mailing list