Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

+0 This proposal may be worth re-considering.  I've seen the problem arise in 
practice on multiple occasions.  I suspect that it will continue to give people 
trouble.

Right now, a bool is-a int that 1) only has two singleton instances equal to 
zero and one, 2) has a different repr, and 3) has the & | and ^ operations 
redefined to return instances of bool.

I think we could also override the ~ operation.  That would be a Liskov 
violation, making bools slightly less substitutable for ints, but it does so in 
a way that is intuitive and likely to match what a user intends when inverting 
a bool.

----------
nosy: +rhettinger, tim.peters
status: closed -> open

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37831>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to