For a MixedUnits instance , and a sequence
Mmix like the one returned by the .singleToMix() method, this method returns
formatted values as a list of strings. All but the last
value will be displayed as integers. You can specify
how many digits of precision will be displayed after the
decimal point in the last value as argument decimals, which defaults to zero.
M.format ( mix, decimals=0, lz=False )
By default, values take only as many digits as they need.
If you would like all the values left-zero-padded to have
at least two digits before the decimal, pass lz=True.
For example, this would format the mixed-unit angle 12° 13′ 59.999″ with one digit after the decimal point of the seconds string:
>>> dmsSystem = MixedUnits ( (60, 60) ) >>> print dmsSystem.format ( (12, 13, 59.999), 1 ) ['12', '13', '59.9'] >>> print dmsSystem.format ( (1,2,3), 3, lz=True ) ['01', '02', '03.000']
It could be argued that the result in this case should be
['12', '14', '0.0']. The package will opt
for truncation instead of rounding. If this is a
problem, consider using more precision.