I have never seen f-strings! It's my lucky day! https://xkcd.com/1053/
Time to refactor the project I am currently working on that is loaded with `str.format()`
Time to refactor the project I am currently working on that is loaded with `str.format()`
s = "this is {}"
print(s.format("possible"))
but you cannot do that with f-strings because they are resolved on definition, so you could do something like this: for message in messages:
print(f"The message is {message}")
But not this: s = f"The message is {message}"
for message in messages:
print(s)
This is the same drawback of JavaScript's Template Literals [0].EDIT: Fix syntax in examples.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
x, y = 1, 2
print(f'{x=}, {y=}')