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

Guido van Rossum guido at python.org
Sat Mar 8 02:03:39 CET 2014


On Fri, Mar 7, 2014 at 4:48 PM, Donald Stufft <donald at stufft.io> wrote:

>
> On Mar 7, 2014, at 12:17 PM, Guido van Rossum <guido at python.org> wrote:
>
> If I had to do it over again I would *definitely* never make a time value
> "falsy". The datetime module was conceived long ago, when the dangers of
> falsy objects that weren't clearly trying to be "like numbers" or "like
> collections" weren't so clear. Today I would argue that times aren't enough
> "like numbers" to qualify.
>
> The only question left in my mind is how safe it is to change the current
> behavior, given that it's been documented and implemented for over a
> decade. If this was for Python 3.0 (or even 3.1) I would definitely vote
> for fixing it, damn the torpedoes. But given that we're talking about 3.5,
> I'm more hesitant. It's also not something for which a deprecation warning
> would work well. (When would it be issued? Whenever bool(<time>) is called?
> Or only when it's about to return False?)
>
> Still, my intuition tells me that it's pretty much a nuisance feature and
> few people have actually relied on it, so I'd be okay with fixing (and
> breaking!) this in 3.5, perhaps after a thorough search for how much the
> feature is actually relied upon and how legitimate or important those uses
> are. A search should *also* try to unearth code that is technically
> *broken* by the current behavior. I would expect there to be quite a lot of
> the latter kind, and very few of the former.
>
> Hrm, I'm not actually sure how to even achieve such a search. Due to
> Python's dynamic nature it's pretty hard to determine what type is being
> used in a boolean expression, if that data is even available (It could be
> coming from a database or some other data source).
>
> Do you have any idea how to do such a search?
>

I know someone at Sourcegraph who thinks he knows how to modify Sourcegraph
to do it.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140307/67d53f0a/attachment.html>


More information about the Python-ideas mailing list