I am using Python's format mini-language to reference a dictionary. For one float in a dictionary, I would like to print it without the decimal point.
For example:
a_dict = {'a_float' : 321.5241,
'b_float' : 0.011322,
'c_float' : 24.12354}
out = ('1 25142U {a_float:9.3f}\n'
'2 {b_float}{c_float:10.3f}').format(**a_dict)
print out
Returns:
>>> 1 25142U 321.524
>>> 2 0.011322 24.123
However, I would like to format b_float (to remove '0.') such that printing out returns:
>>> 1 25142U 321.524
>>> 2 011322 24.123
Is this possible within the context of mini-language format specifications?
I'm aware this can be done by (a) passing in the individual items (and editing them in the argument) instead of the dictionary itself or by (b) post-processing the out string, but I was wondering if Python's mini-language is sophisticated enough to simplify this problem solely to the format specifications of the mini-language.
(For those interested in the motivation for this, I'm trying to print out a TLE from a dictionary of satellite parameters. Google/Wikipedia will probably tell you more if you're interested, but the location of each character is important, and it assumes the decimal place for some items like the eccentricity.)