08/03/08 14:50:49
>>> a = {'hoge': 'fuga', 'hige': 'hage'}
>>> '%(hoge)s' % a
'fuga'
とか、
>>> b = {'moge': a}
>>> '%(moge)s' % b
"{'hige': 'hage', 'hoge': 'fuga'}"
とかは便利なのは分かったんですが、
>>> '%(moge[hoge])s' % b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'moge[hoge]'
>>> "%(moge['hoge'])s" % b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: "moge['hoge']"
ネストされたhashへのアクセスは出来ないんでしょうか?