←back to thread

620 points tambourine_man | 1 comments | | HN request time: 0.256s | source
Show context
metrognome ◴[] No.43754478[source]
Zen of Python in 2025:

  There should be one-- and preferably only one --obvious way to do it.
Python String Formatting in 2025:

- t-strings

- f-strings

- %-operator

- +-operator

- str.format()

replies(4): >>43754501 #>>43754671 #>>43756716 #>>43756756 #
1. davepeck ◴[] No.43754671[source]
And $-strings (PEP 292) as well. :-)

I see each of these as distinct but overlapping; I'm (slowly) writing a guide to string formatting with all of these in mind, trying to emphasize when I'd choose one over the other. (fwiw I personally avoid % and + these days; $ is pretty uncommon in practice; f-, t-, and .format() all seem to have good unique uses.)