You haven't seen the full depth yet. Suppose that you encountered with this line:
print(f"{n:.2g}")
What will it print? Here is the official explanation from https://docs.python.org/3.12/library/string.html#formatspec: g - General format. For a given precision p >= 1, this rounds the number to p significant digits and then formats the result in either fixed-point format or in scientific notation, depending on its magnitude. A precision of 0 is treated as equivalent to a precision of 1.
The precise rules are as follows: suppose that the result formatted with presentation type 'e' and precision p-1 would have exponent exp. Then, if m <= exp < p, where m is -4 for floats and -6 for Decimals, the number is formatted with presentation type 'f' and precision p-1-exp. Otherwise, the number is formatted with presentation type 'e' and precision p-1. In both cases insignificant trailing zeros are removed from the significand, and the decimal point is also removed if there are no remaining digits following it, unless the '#' option is used.
With no precision given, uses a precision of 6 significant digits for float. For Decimal, the coefficient of the result is formed from the coefficient digits of the value; scientific notation is used for values smaller than 1e-6 in absolute value and values where the place value of the least significant digit is larger than 1, and fixed-point notation is used otherwise.
Positive and negative infinity, positive and negative zero, and nans, are formatted as inf, -inf, 0, -0 and nan respectively, regardless of the precision.
Make sense? You now should be able to see why it's called f-string.Yes, it's a generalisation of `%g` in f-string's ancestor printf(3). This is what people expect to find in formatting templates.
I have been under general anesthesia three times, and this is the thing that sticks with me too: it’s a dress-rehearsal for death. The conclusions you come to by going through it are obvious in retrospect but nonetheless interesting:
You have no conscious experience or memory of the moment when you go under and your consciousness is severed. There is only the lead-up, usually the anesthesiologist saying they’re about to start putting the drugs into your arm, or asking you to count down. The next conscious event in your life is waking up in the recovery room. It’s obvious to say, but you could die while under anesthesia and you would never know. Your conscious life up to the moment you went under would be the same. I think it was Wittgenstein who said that Death is not an event in life, and after experiencing anesthesia I suppose I get what he meant.
> I've never felt as much peace as I do right before going under anesthesia.
Same, but I don’t place a lot of stock in it - like you say, it’s the drugs. I asked my anesthesiologist what he’d be giving me to relax me before I went under and he said fentanyl.
> Death, therefore, the most awful of evils, is nothing to us, seeing that, when we are, death is not come, and, when death is come, we are not.
https://en.wikisource.org/wiki/Letter_to_Menoeceus