On Thu, Sep 15, 2016 at 6:59 AM, Lawrence D’Oliveiro
<lawrenced...@gmail.com> wrote:
> On Thursday, September 15, 2016 at 8:13:05 AM UTC+12, Terry Reedy wrote:
>> Because True is the default, object need not and at least in CPython
>> does not have a __bool__ (or __len__) method.
>
> If they had to (in the absence of which a bool() cast would not work), then 
> that would help prevent problems like the one I previously linked to, don’t 
> you think?
>

Nope. The problem came from a *design fault* in which times were
identified with midnight as zero, and were treated as numbers. So
whether implicit or explicit, boolification would have behaved the
same way, and the issue would have happened. I've seen very similar
issues surrounding array/list indices in various languages, and even
file descriptors (stdin is fd 0, and if you simply check the value of
the fd, stdin will appear to be false). Normally they're caught early
in design, but sometimes not. And often, particularly with student or
novice programmers, the workarounds begin looking extremely odd (why
do we start row IDs at 1, even though we have the SQL NULL value
available to mean "no ID at all"?).

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

Reply via email to