Comparisons and sorting of a numeric class....

Terry Reedy tjreedy at udel.edu
Tue Jan 6 21:34:57 EST 2015


On 1/6/2015 9:01 PM, Andrew Robinson wrote:

[snip]

There are very few (about 4) builtin classes that cannot be subclassed. 
  bool is one of those few, float is not.  Go ahead and subclass it.

 >>> class F(float): pass

 >>> F
<class '__main__.F'>
 >>> F(2.3) + F(3.3)
5.6


-- 
Terry Jan Reedy




More information about the Python-list mailing list