[Python-ideas] Please reconsider the Boolean evaluation of midnight
M.-A. Lemburg
mal at egenix.com
Wed Mar 5 23:27:07 CET 2014
On 05.03.2014 23:10, Donald Stufft wrote:
>
> On Mar 5, 2014, at 5:04 PM, M.-A. Lemburg <mal at egenix.com> wrote:
>
>> I don't know what all the fuzz is about. There are lots of types
>> in Python that evaluate to False in certain corner cases, e.g.
>> "", (), [], {}, 0, 0.0, 0j, None, etc.
>>
>> datetime.time(0,0,0) is just another one :-)
>>
> Most of those are pretty easy to reason about being “False”, they all have some
> concept of empty, nothing, etc. Midnight however is not any more or less a time
> than one minute past midnight. Even worse, if you consider not explicitly
> checking for None a bug in that application code, debugging that code is made
> much more difficult because of the fact that for some reason "midnight" is
> considered False.
The reasoning becomes clear if you regard a time value as
number of seconds since midnight (the time of day is a relative
measure). This is 0 for time(0,0,0).
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Mar 05 2014)
>>> Python Projects, Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2014-04-09: PyCon 2014, Montreal, Canada ... 35 days to go
::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-ideas
mailing list