[Python-ideas] Please reconsider the Boolean evaluation of midnight
Alexander Belopolsky
alexander.belopolsky at gmail.com
Wed Mar 5 23:38:53 CET 2014
On Wed, Mar 5, 2014 at 5:16 PM, Ben Finney <ben+python at benfinney.id.au>wrote:
> .. midnight is not special in
> the way “empty” or “zero magnitude” are. Midnight is an arbitrary point
> on a continuum, ..
>
Tell that to people who gather in the Times Square on New Year Eve!
It is very common to implement time-of-day in the languages that lack a
dedicated class as seconds since midnight or fraction of a 24 hour day or
any similar scheme. In all these schemes midnight is false in boolean
context.
Note that when datetime module was introduced, Python did not have a time
class and people were using int or float to denote time-of-day.
Compatibility with older schemes could be part of the original motivation.
It also made more sense when the dunder method was spelled __nonzero__.
Whatever the reason was - this is a well established feature and it won't
change.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140305/bcce54e8/attachment-0001.html>
More information about the Python-ideas
mailing list