[Python-ideas] Please reconsider the Boolean evaluation of midnight
Donald Stufft
donald at stufft.io
Wed Mar 5 23:28:08 CET 2014
On Mar 5, 2014, at 5:27 PM, M.-A. Lemburg <mal at egenix.com> wrote:
> 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).
Except time isn’t number of seconds since midnight.
>
> --
> 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/
-----------------
Donald Stufft
PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140305/0f874a63/attachment.sig>
More information about the Python-ideas
mailing list