Isn't bool __invert__ behaviour "strange"?

Saizan sanzhiyan at
Fri Sep 22 10:08:20 EDT 2006

Why subclassing bool from int either __invert__ or __neg__ haven't been
overrided to produce a boolean negation? I suspect backwards
compatibility or something alike, but I still wonder..

And since bool can't be subclassed, to have a type like bool but with
boolean negation what do you suggest? A wrapper maybe?

(I would use it so I can evaluate user-defined boolean expression
creating istances of his/her variables in my namespace and than eval()
his/her expression)

More information about the Python-list mailing list