python勉強 - 変数を文字列に展開

$ cat foo.py
a = 'hoge'
b = 'fuga'
print 'foobar %s %s' % (a, b)
print 'foobar %(a)s %(b)s' % locals()
$ python foo.py
foobar hoge fuga
foobar hoge fuga