Is it possible to use a variable inside of a Python string formatting specifier?
I have tried:
display_width = 50 print(\'\\n{:^display_width}\'.form
It seems like since this question was first posted, python introduced f-strings. See this web page for info.
>>> name = 'Fred' >>> age = 42 >>> f'He said his name is {name} and he is {age} years old.' He said his name is Fred and he is 42 years old.