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

Steven D'Aprano steve at pearwood.info
Thu Mar 6 11:52:53 CET 2014


On Thu, Mar 06, 2014 at 05:41:11PM +1300, Greg Ewing wrote:
> Steven D'Aprano wrote:
> >There's also the argument from consistency: midnight is the zero point 
> >of the day, and zero is falsey.
> 
> Regarding midnight as a "zero point" is an arbitrary
> convention.

True, as I mentioned in another post.

Nevertheless, we have many arbitrary conventions enshrined in Python.
Using base 10 for the representation of numbers, instead of, say, 
balanced ternary notation, is an arbitrary convention. Numbering 
sequences from 0 is another.

If you would prefer another convention for the zero point of the day 
(say, midday, dusk, dawn, or 2:15pm) then feel free to subclass 
datetime.time :-)

Or even no zero point at all. Tossing out a wild idea, why not leave 
datetime.time alone and add a new class which is exactly the same but is 
always truthy? That doesn't break backward compatibility, and so it 
could happen immediately (too late for 3.4, but certainly for 3.5).

All we need is an appropriate name, and a decision as to which ought to 
inherit from which. The bike-shedding should be over by 3.5 alpha 1 
*wink*

Despite my quip about the bike-shedding, I am actually serious. 

-- 
Steven


More information about the Python-ideas mailing list