42
top 15 comments
sorted by: hot top controversial new old
[-] charokol@lemmy.world 14 points 4 weeks ago

Didn’t think I’d learn anything new in this article, but I never knew about f-string’s self-documenting expression syntax. I’ve been doing it myself like a chump!

[-] monica_b1998@lemmy.world 4 points 4 weeks ago

lol, don't be too hard on yourself!

[-] charokol@lemmy.world 7 points 4 weeks ago

I’m not! I’m excited to forget this exists the next time it would be convenient for me to remember it 😋

[-] olafurp@lemmy.world 9 points 4 weeks ago

I worked in python when f-strings were pretty new. Didn't realise why you would use anything else. It just reads better.

[-] Michal@programming.dev 4 points 4 weeks ago

Most importantly you can't use them with translated strings, so it's not usable for user facing strings unless you don't care. This limits fstring usefulness a lot in the projects I work on.

[-] Badabinski@kbin.earth 9 points 4 weeks ago

Luckily, there's now t-strings (e.g. t"{buh}") for that use case (among many others). Here's the PEP: https://peps.python.org/pep-0750/

[-] itsathursday@lemmy.world 3 points 4 weeks ago

What annoyed me moving from % to format was the loss of “formatting” floats to integers with “{:d}”, now you get a ValueError

[-] ZoteTheMighty@lemmy.zip 5 points 4 weeks ago

{:.0f} always works though for floats or ints

[-] itsathursday@lemmy.world 2 points 4 weeks ago

Ah nice one

[-] slag@lemmy.dbzer0.com 3 points 4 weeks ago

And here I thought f-strings were something that happen when others are forced to read my code.

[-] NotSteve_@lemmy.ca 3 points 4 weeks ago* (last edited 4 weeks ago)

F-strings and .format() are two features I miss from Python whenever I'm writing stuff in another language. The syntax is just so minimal yet powerful

[-] Vulwsztyn@programming.dev 1 points 3 weeks ago
[-] NotSteve_@lemmy.ca 2 points 3 weeks ago

Go mainly. fmt has some functions to do the same sort of formatting but I loved the minimal syntax in Python. JavaScript has a really nice syntax for it as well actually

[-] Vulwsztyn@programming.dev 1 points 3 weeks ago

reasonable answer

[-] Stefan_S_from_H@piefed.zip 0 points 4 weeks ago

Formatting strings, the running gag of the Python community.

this post was submitted on 02 May 2026
42 points (100.0% liked)

Python

7931 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 3 years ago
MODERATORS