[Python-ideas] bool(datetime.time(0, 0))

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon May 7 18:24:21 CEST 2012


On Mon, May 7, 2012 at 12:06 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Why do you want to reproduce it?

If I am porting my software to the hypothetical Python 3.4 and see
that the time.__bool__ changed, I would prefer to simply replace every
occurrence of time tested for truth with something equivalent.  In a
porting scenario, I don't want to second guess the intent of the
original programmer or "improve" the code.

> Does midnight warrant any special shortcut for testing?

I never needed it, but apparently it is common enough for users to
notice an complain.  That's why I asked my original question: if
you've seen a time variable been tested for truth, was it a bug that
can be fixed by a change in time.__bool__ or a deliberate test for the
midnight value?

> Especially one that is confusing to many readers.

I have a feeling that "readers" here are readers of documentation or
tutorials rather than readers of actual code.  If this is the case, we
can discuss how to improve the documentation and not change the
behavior.



More information about the Python-ideas mailing list