[Python-ideas] Please reconsider the Boolean evaluation of midnight
Ryan Hiebert
ryan at ryanhiebert.com
Wed Mar 5 16:50:04 CET 2014
On Wed, Mar 5, 2014 at 9:37 AM, Paul Moore <p.f.moore at gmail.com> 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". 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. 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."""
>
> Your code is ignoring documented behaviour. Worse, your code can
> clearly be improved by being explicit in your test, 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.
>
> Or, perhaps, even though he wouldn't be able to use this change right
away, he'd just like to see Python be better. I can't see that there's
going to come a better time to discuss this issue than the present, thus it
seems to me that you're suggesting that this odd and illogical behavior
continue forever, simply because it's been documented.
The backward compatibility and migration path still need to be addressed,
but it seems that we are disagreeing on whether this strange behavior
should ever change. I think that, at some point, it should. If we ever
agree on that, then we can start thinking about when.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140305/f158fa02/attachment.html>
More information about the Python-ideas
mailing list