We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__format__
Hi, I think it would be very helpful to support the formatting of measures by adding the following definition to the MeasureBase class:
MeasureBase
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
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi, I think it would be very helpful to support the formatting of measures by adding the following definition to the
MeasureBase
class:This would allow the user to write something like this (e.g. in Python 3.6+):
The text was updated successfully, but these errors were encountered: