python: Use the variables defined in the string format as they are
Note that it was convenient.
Pass locals () to format ().
ipython
name = 'Taro'
country = 'Japan'
print("I'm {name} from {country}.".format(**locals()))
stdout
I'm Taro from Japan.
reference
- http://stackoverflow.com/questions/11764900/using-locals-and-format-method-for-strings-are-there-any-caveats
- http://stackoverflow.com/questions/1550479/python-is-using-vars-locals-a-good-practice
- http://qiita.com/twitte_raru/items/17f0e589252e703b2daa