TIL

Variables in f-strings

You can use variables in f-string formatting instructions by wrapping them in additional curly brackets.

>>> text = "Hello World"

>>> f"{text:.>20}"
'.........Hello World'

>>> width = 20
>>> f"{text:.>{width}}"
'.........Hello World'

This is not a feature of the Python 3.12 f-string formaliztion and does work in older Python versions just fine.