String formatting with the format string syntax

Andre Alexander Bell post at andre-bell.de
Tue Sep 14 19:14:02 EDT 2010


On 09/14/2010 08:20 PM, Miki wrote:
> You can use ** syntax:
>>>> english = {'hello':'hello'}
>>>> s.format(**english)

Thanks for your answer. Actually your answer tells me that my example 
was misleading. Consider the template

s = 'A template with {variable1} and {variable2} placeholders.'

I'm seeking a way to extract the named placesholders, i.e. the names 
'variable1' and 'variable2' from the template. I'm not trying to put in 
values for them.

I hope this is clearer.

Thanks again


Andre




More information about the Python-list mailing list