[Python-Dev] bool does not want to be subclassed? (original) (raw)
Bob Ippolito bob at redivi.com
Thu Feb 12 15:02:38 EST 2004
- Previous message: [Python-Dev] bool does not want to be subclassed?
- Next message: [Python-Dev] bool does not want to be subclassed?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Feb 12, 2004, at 2:50 PM, Aahz wrote:
On Thu, Feb 12, 2004, François Pinard wrote:
Hi, people. I just noticed this:
class booleen(bool): ... def repr(self): ... if self: ... return "Vrai" ... return "Faux" ... Traceback (most recent call last): File "", line 1, in ? TypeError: type 'bool' is not an acceptable base type Just to bolster Francois's case, I ran into this precise use case a week ago myself (where I wanted a bool but needed to change the output string). Didn't bother complaining about it, though. ;-)
Shouldn't you be "adapting" the objects for display with some kind of value transformer.. instead of trying to change the objects themselves in the "model"? You could do this with something like PyProtocols, for example. You really have to do something like this in most cases anyway, because repr gets coerced to str if you use the repr() function.
-bob
- Previous message: [Python-Dev] bool does not want to be subclassed?
- Next message: [Python-Dev] bool does not want to be subclassed?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]