On 10/26/2014 12:15 AM, Steven D'Aprano wrote:
Ben Finney wrote:

Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes:

I suspect that Guido and the core developers disagree with you, since
they had the opportunity to fix that in Python 3 and didn't.

That doesn't follow; there are numerous warts in Python 2 that were not
fixed in Python 3. As I understand it, the preservation of bool–int
equality has more to do with preserving backward compatibility.

On reviewing PEP 285, I think it is safe to say that Guido *explicitly*
wants bools to be ints, not just for backwards compatibility:

     4) Should we strive to eliminate non-Boolean operations on bools
        in the future, through suitable warnings, so that for example
        True+1 would eventually (in Python 3000) be illegal?

     => No.

        There's a small but vocal minority that would prefer to see
        "textbook" bools that don't support arithmetic operations at
        all, but most reviewers agree with me that bools should always
        allow arithmetic operations.

http://legacy.python.org/dev/peps/pep-0285/

Thank you for digging this up.  I was one of the 'most reviewers'.

Even though filter now returns an iterator, so that one can write

sum(1 for _ in filter(None, iterable_of_bools))

without creating an unneeded itermediate list, I still prefer

sum(iterable_of_bools)

for efficiency not only for the machine but also for me writing and reading.

[snip of fine disquisition on the subject to which I have nothing to add]

--
Terry Jan Reedy


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

Reply via email to