Using f-strings is typically preferable over the format method because f-strings are often more readable. But the string format method can still be quite handy sometimes.
For example, if we wanted to separate the definition of a string template from the usage of that template, we could use the format method:
We can't use an f-string for that situation because f-strings evaluate their expression immediately (whereas the format method can be called on a string at a later time).
Dica da newsletter python morsels útil para https://github.com/splor-mg/atividades/issues/81.
====
Using f-strings is typically preferable over the format method because f-strings are often more readable. But the string format method can still be quite handy sometimes.
For example, if we wanted to separate the definition of a string template from the usage of that template, we could use the format method:
We can't use an f-string for that situation because f-strings evaluate their expression immediately (whereas the format method can be called on a string at a later time).