Comparisons and sorting of a numeric class....

Chris Angelico rosuav at
Tue Jan 13 06:30:53 CET 2015

On Tue, Jan 13, 2015 at 3:57 PM, Steven D'Aprano <steve at> wrote:
> On Tue, 13 Jan 2015 09:35:43 +1100, Chris Angelico wrote:
>> Subclassing bool breaks this invariant, unless you never instantiate the
>> subclass, in which case it's completely useless.
> Not necessarily. A class that you never instantiate, but use as an object
> itself, is another way of implementing the singleton design pattern.
> Obviously all the methods have to be class methods, but it is doable.
> But wacky exceptions like subclasses that aren't instantiated aside,
> normally if you subclass something you intend to instantiate it.

True, I should have said "probably useless" instead of "completely
useless". :) There's always *something* you could do with it.


More information about the Python-list mailing list