I have a python program that reads floating point values using the following regular expression
(-?\d+\.\d+)
once I extract the value using float(match.group(1)), I get the actual floating point number. However, I am not able to distinguish if the number was 1.2345678 or 1.234 or 1.2340000.
The problem I am facing is to print out the floating point value again, with the exact same formatting. An easy solution is to "split and count" the floating point value when still a string, eg splitting at the decimal point, and counting the integer part length and the fractional part length, then create the formatter as
print "%"+str(total_len)+"."+str(fractional_len)+"f" % value
but maybe you know a standard way to achieve the same result ?