datetime.time and midnight

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Feb 22 02:20:31 EST 2009


En Sat, 21 Feb 2009 21:55:23 -0200, MRAB <google at mrabarnett.plus.com>  
escribió:

> Ethan Furman wrote:
>> Greetings, List!
>>  I was curious if anyone knew the rationale behind making midnight  
>> False?
>>  --> import datetime
>> --> midnight = datetime.time(0,0,0)
>> --> bool(midnight)
>> False
>>  To my way of thinking, midnight does actually exist so it should be  
>> true.  If datetime.time was measuring an *amount* of time, rather than  
>> a certain point during the day, then a time of 0:0:0 should certainly  
>> be False as it would mean no time had passed.  However, since midnight  
>> does indeed exist (as many programmers have observed when deadlines  
>> approach ;) I would think it should be true.
>>
> I think it's because midnight is to the time of day what zero is to
> integers, or an empty string is to strings, or an empty container ...

So chr(0) should be False too...

-- 
Gabriel Genellina




More information about the Python-list mailing list