[Python-Dev] bool does not want to be subclassed?

Tim Peters tim.one at comcast.net
Thu Feb 12 16:09:28 EST 2004


See
    http://mail.python.org/pipermail/python-dev/2002-March/020822.html

    [Guido]
    I thought about this last night, and realized that you shouldn't be
    allowed to subclass bool at all!  A subclass would only be useful
    when it has instances, but the mere existance of an instance of a
    subclass of bool would break the invariant that True and False are
    the only instances of bool!  (An instance of a subclass of C is also
    an instance of C.)  I think it's important not to provide a backdoor
    to create additional bool instances, so I think bool should not be
    subclassable.



More information about the Python-Dev mailing list