[issue37831] bool(~True) == True

Raymond Hettinger report at bugs.python.org
Tue Aug 13 21:20:04 EDT 2019


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Essentially we've got two competing desires:

* Given that & | and ^ are closed under bools,
  it would be nice for ~ to be closed as well.
  NOT isn't a reasonable alternative because
  of its operator precedence.

* Given that bool is a subclass of int,
  its operations should give results equivalent
  to what you would get for ints.

When reopening this, my thought was that the
first desire should win based on practicality-
beats-purity.  In the context of bools, the
current ~ operator violates user expectations
and there isn't a reasonable alternative that
has the correct precedence.

But in the face of opposition to the idea,
am willing to just let it die.  In the scheme
of things, it isn't important.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37831>
_______________________________________


More information about the Python-bugs-list mailing list