On Mar 5, 2014, at 5:04 PM, M.-A. Lemburg
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/ _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
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. That is the real problem here, sure people should be using ``is None`` checks but until people are perfect and never write buggy code, we have to contend with the fact that sometimes people will not write ``is None``. Making that particular error harder to debug is doing nothing but wasting their time and having Python be punitive for what in many cases may be a mistake. ----------------- Donald Stufft PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA