Python String Interpolation
Comments debate Python's f-strings versus interpolation in other languages like JS and Ruby, discuss proposals for t-strings or default interpolation, and compare readability, safety, and ergonomics.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Next time can you to do Python's string interpolation? ;-) It's much more pleasant to read (when properly used).
Is this supposed to be better than python? "Every string is an f-string, make sure you don't accidentally miss some interpolation." sounds like a step down, not like an improvement to me!
You don't with f-strings because they're substituted eagerly. You could with the new t-strings proposed here because you can get at the individual parts.
Since when string interpolation is a such mysterious and arcane feature?
What kind of special string will be added next? We already have f-strings, .format, %s ...
"String interpolation" is a term for the purpose that the string.format syntax serves.
I like strings to be interpolated by default, and that's one of the most annoying things about python.
How is "#{fname} #{surname}" better than f'{fname} {surname}' ?
They should have gone step further and done string interpolation how C# and JS can do. Really nice to use and avoids errors.
It's string interpolation where you can provide an expression, not just a variable.> String interpolation is common in many programming languages which make heavy use of string representations of data, such as Apache Groovy, Kotlin, Perl, PHP, Python, Ruby, Scala, Swift, Tcl and most Unix shells. Two modes of literal expression are usually offered: one with interpolation enabled, the other without (termed raw string). Placeholders are usually represented by a bare or a named sigil (ty