3 ms·
It will be an error, the {something} will be gone by the time the second .format runs. It might help to realize the f-string is just syntactic sugar for a .for
by mixmastamyk 10y ago
It will be an error, the {something} will be gone by the time the second .format runs.
It might help to realize the f-string is just syntactic sugar for a .format() call.
- hyperbovine 10y agoIt's not obvious which .format() is evaluated first, though. For 'in-line' string interpolation I think the f'' syntax wins. .format() is still nice for template-style interpolation though. For this reason, and to avoid situations like the parent, I think it should be made static, so that you could write: >>> formatted = str.format(template, var1='a', var2=3) Of course, this will never happen due to the need to maintain backward compatibility.
- mixmastamyk 10y agoIn python, function calls start from left and continue to the right. Though f'' doesn't look like a function call, in practice it is.