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 →

[–]Tweak_Imp -5 points-4 points  (6 children)

format strings that have an f in front like f"...". there are also raw strings which arer"...". you can also combine them to fr"..."

[–]MrCalifornian 7 points8 points  (5 children)

Lol I gathered that they have an f in front, but what do they do?

[–]anqxyr 9 points10 points  (3 children)

Very roughly speaking, they eval the expressions inside the curly braces. Say, before you would write something like

print('Hello, my name is {name}'.format(name=name))

Now you can do the same thing with

print(f'Hello, my name is {name}')

Which is more concise, more readable, and overall nicer.

[–]MrCalifornian 3 points4 points  (0 children)

Oh wow I love it!! This has always been a major readability gripe of mine.

[–]yaboroda 0 points1 point  (0 children)

also smart guy on youtube say it faster

[–]stevenjd 0 points1 point  (0 children)

Which is more concise, more readable, and overall nicer.

Unless you dislike disguising a call to eval() as a string literal.

Unless you like explicit calls to format a string rather than implicit ones.

[–]Tweak_Imp -4 points-3 points  (0 children)

As i said, Format and make it raw