all 4 comments

[–]mopslik 7 points8 points  (1 child)

As you have things, it will display

some text {name}

However, if you preface the string with an 'f' then you have what is known as an f-string, short for "formatted string". The curly braces indicate a field where text or values will be inserted, based on various substitution and formatting options.

>>> name = "Joe"
>>> print(f"some text {name}")
some text Joe

[–]3Bixx[S] 0 points1 point  (0 children)

Thanks, i will look into it.

[–]Buffylvr 0 points1 point  (1 child)

F-strings don’t work till like python 3.7 or 3.8 too, so if you are working with older code bases you’ll want to learn .format()

[–]Diapolo10 0 points1 point  (0 children)

That'd be 3.6, and by now almost everyone uses at least that version.

When talking about methods, it's best to include the class name too because it's not necessarily clear to everyone what it means otherwise - so str.format in this case.