[Python-ideas] Please reconsider the Boolean evaluation of midnight

M.-A. Lemburg mal at egenix.com
Thu Mar 6 14:21:52 CET 2014


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/


More information about the Python-ideas mailing list