31 Aug
2016
31 Aug
'16
2:35 a.m.
On Wed, Aug 31, 2016 at 12:05 PM, Steven D'Aprano
(5) Is this really something that format() needs to understand? We can get a *much* richer and more powerful interface by turning it into a generalise numeric pretty-printing library, at the cost of a little less convenience.
Or just have a subclass of int or float that defines __format__, and can do whatever it likes - including specifying the scale, if you so choose. Say, something like: {:s} -- autoscale, prefix {:S} -- autoscale, full word {:sM} -- scale to mega, print "M" {:SM} -- scale to mega, print "Mega" etc ChrisA