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

Shai Berger shai at platonix.com
Wed Mar 5 17:05:15 CET 2014


On Wednesday 05 March 2014 17:37:14 Paul Moore wrote:
> On 5 March 2014 15:19, Shai Berger <shai at platonix.com> wrote:
> > What, other than "bug", do you call behavior that isn't sensible?
> 
> "Unfortunate".

That's unfortunate. You miss a lot of bugs.

> I'm not arguing that the behaviour is useful. Or
> sensible. What I'm arguing, and you're missing, is that the behaviour
> is as documented, and so can't be changed without backward
> compatibility implications.

I think I have given ample room to backwards-compatibility considerations.

> Specifically, see
> http://docs.python.org/3.4/library/datetime.html#time-objects:
> 
> """in Boolean contexts, a time object is considered to be true if and
> only if, after converting it to minutes and subtracting utcoffset()
> (or 0 if that's None), the result is non-zero."""
> 
Yes, I know. It's mentioned in the bug.

> Your code is ignoring documented behaviour. Worse, your code can
> clearly be improved by being explicit in your test,

We disagree. I don't see adding "is not None" as an improvement at all. I see 
it as adding unnecessary ceremony. If you really like that much explicitness, 
use Java.

> and yet you'd
> rather argue that the Python developers implement a backward
> compatibility break which you won't even be able to take advantage of
> until you drop support of versions of Python before 3.7.
> 

What Ryan said: The code in question will not benefit from this change; it is 
Python 2.7, and will probably be rewritten from scratch before anything comes 
out of this. This is about fixing my projects a decade from now.

Shai.


More information about the Python-ideas mailing list