On 06.03.2014 10:52, Antoine Pitrou wrote:
Le 06/03/2014 09:35, M.-A. Lemburg a écrit :
Just in case you're looking for a relevant use case:
Having bool(time(0,0,0)) allows you to quickly check whether you are dealing with a datetime value with (non-trivial) time part or not.
This sounds like the kind of shortcut that only an expert would know to take, not something that's actually a good design decision. It's as though pathlib.Path('') evaluated to false for some obscure use case that I cared about.
It doesn't ? :-)
It is not a coincidence, IMO, that the three persons arguing that the current behaviour is reasonable are implementors of datetime modules: you, Tim and Alexander. All other people find the behaviour baffling.
I'm not so sure. Of course, people who have been doing date/time stuff will jump into discussions that deal with them, but the same argument triggering this thread could have applied to other Python types and you would then have a different group of people argue for plausibility of the choice. I find it strange that the only argument against having time(0,0,0) evaluate to False in a boolean context is a wrongly used None test. This argument can be applied to lots of other types as well, where the buggy None test masks errors. Perhaps someone could present at least one compelling argument that is not based on wrong usage of None in if statements. -- 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/