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

Tim Peters tim.peters at gmail.com
Thu Mar 6 05:13:59 CET 2014


[Tim]
>> That's there because `utcoffset()` is defined to return minutes.

[Bruce Leban]
> It returns either minutes or a timedelta:

I wrote the code and I wrote the docs.  I know what it does ;-)  Going
into tedious detail (as the docs do) is simply irrelevant to the point
here:  utcoffset() returns minutes.  Whether that's _spelled_ as an
integer or as a timedelta, minutes is minutes is minutes.

> ...

>> A rule is needed to specify how the naive time object and `utcoffset()`
>> interact to define the result.

> Not sure why you attach 'naive' to time. Time objects carry units with them,
> unlike integers. I would say 'naive time value' in reference to an integer.

Start with the second paragraph of the datetime docs:

    There are two kinds of date and time objects: "naive" and "aware".

Etc.  I attached "naive" to "time" to make clear that I mean the time
object stripped of its tzinfo attribute.  An aware time object is a
naive time object with a non-None tzinfo attribute.

> ....
> The above part is the key part of my suggested improvement. Reading the
> current documentation, the fact that it means midnight local time is falsey
> is not obvious.

Before this thread, I had never heard anyone express it as "midnight
local time" before.  Now that I have heard it, eh - I don't find it a
helpful way to view it.


More information about the Python-ideas mailing list