[Python-ideas] Please reconsider the Boolean evaluation of midnight
Alexander Belopolsky
alexander.belopolsky at gmail.com
Wed Mar 5 18:27:21 CET 2014
On Wed, Mar 5, 2014 at 11:38 AM, Shai Berger <shai at platonix.com> wrote:
> So, I rephrase my request: Would anybody object to a silent warning issued
> whenever a time-object is evaluated as Boolean?
>
I would. Users should not be penalized for using a documented behavior.
There are legitimate uses for bool(midnight) being False. Midnight is
special in many contexts. For example, it is uncertain whether midnight
belongs to the previous or next day. If your application wants to group
midnight differently from other times - it is perfectly fine to use "if
dt.time()" instead of a more verbose "if dt.time() != datetime.time(0, 0)".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140305/3f930cd1/attachment.html>
More information about the Python-ideas
mailing list