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

Python

7907 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 2 years ago
MODERATORS
top 13 comments
sorted by: hot top controversial new old
[–] NotSteve_@lemmy.ca 0 points 3 days ago* (last edited 3 days ago) (1 children)

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 0 points 1 day ago (1 children)
[–] NotSteve_@lemmy.ca 0 points 23 hours 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

[–] olafurp@lemmy.world 0 points 3 days ago (1 children)

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 0 points 3 days ago (1 children)

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 0 points 3 days 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/

[–] slag@lemmy.dbzer0.com 0 points 3 days ago

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

[–] itsathursday@lemmy.world 0 points 3 days ago (1 children)

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 0 points 2 days ago (1 children)

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

[–] itsathursday@lemmy.world 0 points 2 days ago

Ah nice one

[–] charokol@lemmy.world 0 points 3 days ago (1 children)

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 0 points 3 days ago (1 children)

lol, don't be too hard on yourself!

[–] charokol@lemmy.world 0 points 3 days ago

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