Comparisons and sorting of a numeric class....

Ethan Furman ethan at stoneleaf.us
Thu Jan 8 01:04:47 CET 2015


On 01/06/2015 07:37 PM, Andrew Robinson wrote:

> Explain; How does mere subclassing of bool break the contract that bool has?
> eg: What method or data would the superclass have that my subclass would not?

bool's contract is that there are only two values (True and False) and only one instance each of those two values (True
and False).  If bool were subclassable, new values could be added with either completely different values (PartTrue) or
with more of the same value (True, ReallyTrue, AbsolutelyTrue) -- hence, broken contract.

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20150107/77254f9e/attachment.sig>


More information about the Python-list mailing list