Isn't bool __invert__ behaviour "strange"?

John Roth JohnRoth1 at jhrothjr.com
Sat Sep 23 18:33:07 EDT 2006


Saizan wrote:
> John Roth wrote:
>
> > The not operator and the bool() builtin produce
> > boolean results. Since bool is a subclass of int,
> > all the integer operations will remain integer
> > operations. This was done for backwards
> > compatability, and is unlikely to change in the 2.x
> > series.
>
> Ok, shame on me, I completely overlooked "not" and it surprises myself
> because it's not like I haven't used it, I just didn't see "not" as an
> operator, maybe because i can't find a __not__ method in bool class.
> (Is it hidden somewhere or is computed in some other way?)

None of the boolean operators have magic methods.
PEP 335 addresses this issue, but it's been sitting
there for over two years with no action. It's probably
lost any traction it ever had.

John Roth




More information about the Python-list mailing list