4 ms·
I fail to see the purpose of f-strings if they end up as complex as printf formatting. Maybe use printf at this point?
by blueflow 1y ago
I fail to see the purpose of f-strings if they end up as complex as printf formatting. Maybe use printf at this point?
- Hamuko 1y agoYou don't really need to use any of these. Really the most useful one is f"{var=}" for us print() debuggers. But f"{var:#x}" is the same as f"{hex(var)}", so feel free to pick whatever you prefer.
- ForceBru 1y agoI think the purpose is to put variables directly in the string literal instead of calling `printf`. Looking at an f-string immediately tells you where each value will be located in the output. `printf` requires you to read the format string, then look at the arguments, then count where a particular value will be printed.
- positr0n 1y agoSometimes you need a formatted string outside of a printf content.