Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmy.world

15 replies

lemmy.world

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!

14

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

7
lemmy.world

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

9
Michalreply
programming.dev

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.

4
lemmy.world

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

3
lemmy.ca

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

3
NotSteve_reply
lemmy.ca

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

2

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

3

You reached the end

Python String Formatting: f-strings vs .format() vs % | Spyke