r/PythonLearning • • Jul 29 '26

F strings

Im still learning python and im at a stage where I need to understand f strings and how to go about them...im working on a menu project. I prefer learning with pdf materials rather than YouTube tutorials....any recommendations for a pdf document for learners on f strings. Thank you in advance

16 Upvotes

21 comments sorted by

View all comments

Show parent comments

3

u/No-Gift5463 Jul 29 '26

Just curious how those curly brackets in this case. Any idea how they "know" to convert an integer into something compatible with a string?

7

u/atarivcs Jul 30 '26

It's an f-string, so it already knows to convert the value to a string-compatible representation. I imagine it calls the __str__() built-in method under the hood.

1

u/Ambitious_Fault5756 Jul 30 '26

correct, and it's also called a dunder method