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.

➡️ Stable 0.9x Programming Languages
2,893
Comments
20
Years Active
5
Top Authors
#6146
Topic ID

Activity Over Time

2007
4
2008
9
2009
23
2010
21
2011
62
2012
57
2013
44
2014
88
2015
231
2016
217
2017
127
2018
112
2019
194
2020
165
2021
292
2022
265
2023
264
2024
240
2025
459
2026
21

Keywords

DX PHP PEP IMO JS SQL IL NET npmjs.com BTW string interpolation strings format python template languages expression backwards compatibility kotlin

Sample Comments

renox Sep 16, 2025 View on HN

Next time can you to do Python's string interpolation? ;-) It's much more pleasant to read (when properly used).

Mond_ Feb 3, 2025 View on HN

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!

wzdd Apr 15, 2025 View on HN

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.

tigershark Mar 14, 2018 View on HN

Since when string interpolation is a such mysterious and arcane feature?

metadat Apr 11, 2025 View on HN

What kind of special string will be added next? We already have f-strings, .format, %s ...

zahlman Jul 19, 2025 View on HN

"String interpolation" is a term for the purpose that the string.format syntax serves.

pbiggar Dec 7, 2016 View on HN

I like strings to be interpolated by default, and that's one of the most annoying things about python.

cutler Jun 19, 2017 View on HN

How is "#{fname} #{surname}" better than f'{fname} {surname}' ?

Ididntdothis Dec 6, 2019 View on HN

They should have gone step further and done string interpolation how C# and JS can do. Really nice to use and avoids errors.

iudqnolq Apr 24, 2021 View on HN

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