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

M.-A. Lemburg mal at egenix.com
Wed Mar 5 23:35:02 CET 2014


On 05.03.2014 23:16, Ben Finney wrote:
> "M.-A. Lemburg" <mal at egenix.com> writes:
> 
>> 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 :-)
> 
> The salient difference is:
> 
> With the former set, they all embody concepts of either “empty” or “zero
> magnitude”. They strongly connote “not there” within their domain of
> values, hence map well to Boolean false.
> 
> With ‘datetime.time’ there is no equivalent: midnight is not special in
> the way “empty” or “zero magnitude” are. Midnight is an arbitrary point
> on a continuum, and is not a “not there” value.

This is true in a date/time continuum, but not true if you regard
time as "time of day". In the latter interpretation, the day starts
at midnight, so the day is "not there" yet at midnight.

> It should not be Boolean false any more than any other time.

Just like with most interpretations, you can just as easily find
one which implies the exact opposite.

It's all smoke and mirrors anyway :-)

Perhaps Tim just wanted to be able to make float(time(0,0,0)) return
0.0 seconds some day. That's what mxDateTime does for time values.

-- 
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