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.

In Java terms bool is a "final" class which means it cannot be subclassed. 
Although Python is not anywhere near as restrictive as Java, and makes a 
virtue out of allowing the programmer to shot themselves in the foot, 
there are some restrictions and this is one of them.


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to