python string format() with dict with integer keys

Viewed 33173

I would like to use Python string's format() to act as a quick and dirty template. However, the dict that I would like to use has keys which are (string representations) of integers. a simplified example follows:

s = 'hello there {5}'
d = {'5': 'you'}
s.format(**d)

the above code throws the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: tuple index out of range

is it possible to do the above?

6 Answers
Related