Isn't bool __invert__ behaviour "strange"?

Saizan sanzhiyan at gmail.com
Fri Sep 22 18:22:14 CEST 2006


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?)

(However (not x) whould be as annoying as 1-x even if a little more
readable (if you consider lispish parentheses readable):
Input expression: (not (not x)&(not y)!(not (z|v)))
Maybe direct eval is just the wrong way of doing this, I should look
for or make muParser bindings for Python instead..)




More information about the Python-list mailing list