How can I format a float so that it doesn\'t contain trailing zeros? In other words, I want the resulting string to be as short as possible.
For example:
<
Use %g with big enough width, for example '%.99g'. It will print in fixed-point notation for any reasonably big number.
EDIT: it doesn't work
>>> '%.99g' % 0.0000001 '9.99999999999999954748111825886258685613938723690807819366455078125e-08'