datetime.time and midnight

Tim Rowe digitig at gmail.com
Sun Feb 22 12:09:29 EST 2009


2009/2/22 Mark Dickinson <dickinsm at gmail.com>:
> On Feb 21, 10:44 pm, Ethan Furman <et... at stoneleaf.us> wrote:
>
>> --> midnight = datetime.time(0,0,0)
>> --> bool(midnight)
>> False
>
> I'd call this a bug.

No more so than zero being false. Zero exists too (check my bank
balance). Once you've accepted non-Boolean types having Boolean
values, the logic of what value they have is always going to be a bit
hairy. If you're unsure of the logic, just test against a value or a
range. After all, what value do you *expect* a time of day to have
when interpreted as a Boolean? If you don't have an expectation, why
are you interpreting it as a Boolean?


-- 
Tim Rowe



More information about the Python-list mailing list