On Wed, Mar 5, 2014 at 11:24 AM, Steven D'Aprano <steve@pearwood.info> wrote:
There's also the argument from consistency: midnight is the zero point
of the day, and zero is falsey. It would be surprising if something
which is essentially zero became truthy.
I don't think it's consistent now.
In Boolean contexts ...
a timedelta object is considered to be true if and only if it isn’t equal to timedelta(0).
a time object is considered to be true if and only if, after converting it to minutes and subtracting utcoffset() (or 0 if that’s None), the result is non-zero.
And the documentation is not exactly clear for understanding when a time object is falsey. In particular, the "converting it to minutes" part seems irrelevant as a time of 1 microsecond from midnight is truthy and timedeltas are not numbers and are not in minutes. Perhaps a reasonable improvement would be to change this to:
a time object is considered to be true unless it represents exactly midnight local time, that is, it's false if subtracting the utcoffset() from the time produces an all-zero result (or it's all-zero to start with if the utcoffset is None).