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.



-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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

Reply via email to