in C#, I can do (#.####), which prints up to 4 significant digits after the decimal point. 1.2 -> 1.2 1.234 -> 1.234 1.23456789 -> 1.2345
Afaik, in python, there is only the c-style %.4f which will always print to 4 decimal points padded with 0s at the end if needed. I don't want those 0s.
Any suggestions for what is the cleanest way to achieve what I need?
One possible solution is to print it first and trim ending 0s myself, but hoping to find more clever ways.