On Sat, Jul 16, 2016 at 9:02 PM, Steven D'Aprano <st...@pearwood.info> wrote:
> On Sat, 16 Jul 2016 08:46 pm, Chris Angelico wrote:
>
>> As Steven says,
>> the default is that they're all truthy, and onus is on the implementer
>> to demonstrate that this object is functionally equivalent to 0 or an
>> empty collection. (And it's possible for ANYONE to get that wrong - cf
>> timedelta.)
>
> I think you're thinking of time values, not timedelta values. Until
> recently, midnight was considered falsey just because it happened to be
> implemented as 0 seconds:
>
> [steve@ando ~]$ python3.3 -c "import datetime;print(bool(datetime.time(0)))"
> False
> [steve@ando ~]$ python3.6 -c "import datetime;print(bool(datetime.time(0)))"
> True
>
> That was a real bug, letting the concrete implementation show through into
> the abstract API by accident, but it's corrected now.
>
> timedelta values, being a difference between two times, have a qualitative
> difference between delta = 0 and every other value. A difference of zero is
> no difference at all, and it makes sense to make that falsey.

Umm, yes. That's the one. Time, not timedelta. My bad. Point still
stands, though - the concept of "midnight" does not truly equate to
"empty" or "zero", and that bug stood for a long time.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to