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

Justin Brown report at bugs.python.org
Thu Mar 13 19:31:36 CET 2014


Justin Brown added the comment:

This behavior conflicts with the other major classes, datetime.date and datetime.datetime. The ostensible reason for this falsy behavior is that midnight represents a fundamental zero point. We should expect to see similar zero points that evaluate to False for the other two classes. However, they do not include such falsy behavior.

In [2]: bool(datetime.datetime(datetime.MINYEAR, 1, 1))
Out[2]: True
In [3]: bool(datetime.date(datetime.MINYEAR, 1, 1))
Out[3]: True

Why don't these classes have any sense of zero at their minimums?

datetime.time.__bool__ should be dropped if for nothing more than consistency.

----------
nosy: +fandingo

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


More information about the Python-bugs-list mailing list