[Python-ideas] Please reconsider the Boolean evaluation of midnight
M.-A. Lemburg
mal at egenix.com
Wed Mar 5 23:04:05 CET 2014
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 :-)
BTW: If you want to test for None, well, then do test for None and
not for some property of None:
if x is None:
print ("x is None, which implies it's False")
print ("Oh, and do note that the inverse is not necessarily true :-)")
In logic:
A -> B does not imply B -> A; it only implies (not B) -> (not A).
in Python again:
if bool(x) is not False:
print ("x is not None")
--
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