[Python-ideas] Please reconsider the Boolean evaluation of midnight
Donald Stufft
donald at stufft.io
Thu Mar 6 14:49:29 CET 2014
On Mar 6, 2014, at 8:21 AM, M.-A. Lemburg <mal at egenix.com> wrote:
> On 06.03.2014 13:08, Nick Coghlan wrote:
>> But perhaps I've been told "midnight is false in boolean context". But
>> which midnight? There are three that apply to me:
>>
>>>>> naivemidnight
>> datetime.time(0, 0)
>>>>> utcmidnight
>> datetime.time(0, 0, tzinfo=datetime.timezone.utc)
>>>>> localmidnight
>> datetime.time(0, 0, tzinfo=datetime.timezone(datetime.timedelta(0, 36000)))
>>
>> Are they all False? No, no they're not (unless your local timezone is UTC):
>>
>>>>> bool(utcmidnight)
>> False
>>>>> bool(naivemidnight)
>> False
>>>>> bool(localmidnight)
>> True
>
> Now this is a what I consider a valid argument for making a change.
>
> Thanks, Nick.
>
> --
> Marc-Andre Lemburg
> eGenix.com
>
> Professional Python Services directly from the Source (#1, Mar 06 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 ... 34 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/
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
Yea Nick put into words what I’ve been attempting to say better than I ever could have :)
-----------------
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/20140306/ad2ed353/attachment-0001.sig>
More information about the Python-ideas
mailing list