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

Antoine Pitrou solipsis at pitrou.net
Wed May 9 08:07:46 CEST 2012


On Tue, 8 May 2012 20:53:58 -0400
Jim Jewett <jimjjewett at gmail.com> wrote:
> 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.

Well, if you've decided upfront that midnight "is zero", then you may
argue it's special. But as others have shown, there's nothing obvious
about midnight being "zero", especially with timezones factored in.
For example, there are no binary operators where midnight is a "zero"
i.e. a neutral element.

Besides, we have a special value called None exactly for the purpose of
representing missing data.

Regards

Antoine.





More information about the Python-ideas mailing list