Python23: cannot inherit from bool?

Carl Banks imbosol at vt.edu
Tue Jan 14 23:16:04 EST 2003


Delaney, Timothy wrote:
>> From: franks at mcs.anl.gov [mailto:franks at mcs.anl.gov]
>> 
>> It seems that 2.3 doesn't allow you to inherit from bool:
>> Could someone explain the reason for this restriction?
> 
> `bool` is a special class which is guaranteed to only ever have two
> instances instantiated (a dualton if you will) - True and False.

"Doubleton" would be better.


> Allowing `bool` to be subclassed would break this guarantee.

This reminds me of a question I've been pondering, in case anyone
knows: Is it the plan that built-in singleton objects (None, Ellipsis,
NotImplemented, ?) will eventually get a new metatype?  Although it
seems like there would be small benefit for built-in objects (the only
tangible thing I can think of is you could ask a singleton type for
its object), it could be used for Python types, too.


-- 
CARL BANKS




More information about the Python-list mailing list