▲ | cloudbonsai 5 days ago | |
You haven't seen the full depth yet. Suppose that you encountered with this line:
What will it print? Here is the official explanation from https://docs.python.org/3.12/library/string.html#formatspec:
Make sense? You now should be able to see why it's called f-string. | ||
▲ | jgtrosh 5 days ago | parent | next [-] | |
Yes, it's a generalisation of `%g` in f-string's ancestor printf(3). This is what people expect to find in formatting templates. | ||
▲ | zahlman 4 days ago | parent | prev | next [-] | |
I don't know why people look at paragraphs of documentation that explain the exact results in strange edge cases (which have to exist because of the underlying complexity; in this example, Python can't change how IEEE-754 works, nor the original C printf specifier they're emulating) and conclude that this proves some strange and unexpected complexity was introduced. When documentation isn't this thorough, people complain about that, too. | ||
▲ | cwilkes 4 days ago | parent | prev [-] | |
Maybe should be called “iq-string” for Interview Question string. |