[Python-ideas] bool(datetime.time(0, 0)) vs missing data
Antoine Pitrou
solipsis at pitrou.net
Wed May 9 18:58:03 CEST 2012
On Wed, 9 May 2012 12:38:19 -0400
Jim Jewett <jimjjewett at gmail.com> wrote:
> Or
> are you just saying that there aren't *any* meaningful binary
> operators on hour-of-the-day, beyond __eq__ and __ne__?
There aren't indeed. __eq__ and __ne__ don't produce a time result, so
they can't be used as a basis for a group. Hence, the notion of a "zero"
which you invoked is undefined here.
> Practicality Beats Purity suggests that at least comparisons should
> work consistently, so that time-of-day can be consistently ordered,
> and that requires a least element. (You could make it noon, or mean
> sunrise, or actual sundown at a certain monument, but you do need
> one.)
Sure, so what? Let's say you are creating a day-of-week class with 7
possible instances, and you make them orderable. Does it mean that the
least of them (say, Monday or Sunday) should evaluate to false?
> > Besides, we have a special value called None exactly for the purpose of
> > representing missing data.
>
> Not really at the moment, since datetime.time doesn't accept it as an
> argument, and itself uses 0 for missing data.
That's bogus. int() doesn't take None as an argument, yet None is
often used to indicate a missing integer argument in other APIs.
This fact is true for most types under the sun. You are just inventing
non-existing contraints.
Regards
Antoine.
More information about the Python-ideas
mailing list