[issue13936] RFE: change bool(datetime.time(0, 0, 0)) to evaluate as True

Nick Coghlan report at bugs.python.org
Thu Mar 6 13:26:41 CET 2014


Nick Coghlan added the comment:

I wrote up a longer post on python-ideas regarding the problems that the current behaviour poses when it comes to inferring a correct mental model for datetime.time(): https://mail.python.org/pipermail/python-ideas/2014-March/026647.html

As part of that, it's also worth noting the current behaviour in boolean context is effectively shorthand for:

    import datetime as dt

    naivemidnight = dt.time(0, 0)
    utcmidnight = dt.time(0, 0, tzinfo=dt.timezone.utc
    if x in (naivemidnight, utcmidnight):
        ...

So if the current boolean behaviour is deprecated and removed, it is easily reproduced through equality checks.

It may also make sense to offer an API to easily calculate seconds since midnight, but that would be a separate issue.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13936>
_______________________________________


More information about the Python-bugs-list mailing list