Was just wondering about how exactly f strings and the curly braces
work.
This is described by Abstract of PEP 498 – Literal String Interpolation following way
(...)F-strings provide a way to embed expressions inside string literals,
using a minimal syntax. It should be noted that an f-string is really
an expression evaluated at run time, not a constant value. In Python
source code, an f-string is a literal string, prefixed with ‘f’, which
contains expressions inside braces. The expressions are replaced with
their values.(...)
Is this a function unique to python?
No. Recent versions of JavaScript have similar feature named Template strings which are enclosed in backtick characters, for example
let letters = "abcd";
for(i=0;i<letters.length;i+=1){
console.log(`Letter ${letters[i]}`)
}
make console output
Letter a
Letter b
Letter c
Letter d