Hi, I think it would be very helpful to support the formatting of measures by adding the following definition to the MeasureBase class:
def __format__(self, format_spec):
return '%s %s' % (
format(getattr(self, self._default_unit), format_spec),
self.unit
)
This would allow the user to write something like this (e.g. in Python 3.6+):
>>> from measurement.measures import Distance
>>> x = Distance(cm=5/7)
>>> print(x)
0.7142857142857143 cm
>>> print(f"{x:.3f}")
0.714 cm
Hi, I think it would be very helpful to support the formatting of measures by adding the following definition to the
MeasureBaseclass:This would allow the user to write something like this (e.g. in Python 3.6+):