Saizan wrote: > 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)
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. I don't remember if this is supposed to change in 3.0. See PEP 3100 and 3099. John Roth John Roth -- http://mail.python.org/mailman/listinfo/python-list