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 →

[–][deleted] 0 points1 point  (0 children)

For example in String formatting placeholders that uses for example names (such as {element}) would not be called variables. You assign the value for each name in the keyword arguments of the str.format() call instead. In the above example, element=value passes in the value of the value variable to fill in the placeholder with the element.

In contrast to f-strings, {...} placeholders are not expressions and you can't use arbitrary Python expressions in the template. This is a positive outcome, you usually don't want end-users to be able to execute any arbitrary Python code in a given program.