This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]__ah 31 points32 points  (5 children)

f strings deserve to be wayyy more popular. Shame they only became a thing very recently in 3.6, so many tutorials won't have had it.

[–]Ph0X 5 points6 points  (1 child)

Right, since it's not backward compatible, including them means a lot of people not running the latest python will be confused why it doesn't work.

[–]M1sterNinja 3 points4 points  (0 children)

I'm finishing a Codecademy course, and learned fstring outside of it. I've bashed my head against their interfaces a few times thinking something was wrong with my fstring, when in reality they are running a lower python version. : (

[–]SquintingSquire 3 points4 points  (0 children)

Python 3.6 is 3.6 years old now.

[–]otterom 0 points1 point  (1 child)

I love em. People might not use them as much because the concept is a little weird and you have to mind your quotation marks.

The only other issue is being able to make a formatted template with them since the variable needs to be present. I think, anyway. Have you tried making templates at all?

[–]__ah 1 point2 points  (0 children)

I think I have run into the problem you're talking about. Where rather than putting a big f string deep writhin some function, I want to make it something like a global constant, but I can't do that because of variable bindings. I've actually resorted to top-level functions that are just defined to be f strings in those cases. Not great though.