how can you format a string of this form in Python 3?
'''{name}{{name}}'''.format(name="bob")
the desired output is: bob{bob}
, but the above gives: bob{name}
.
one solution is to add another argument to format
:
'''{name1}{name2}'''.format(name1="bob", name2="{bob}")
but this is excessive. is there a way to properly escape {
such that inner {x}
can still be interpolated and one can only pass a single name
to format
?