pythonで連想配列を使う
Pythonの場合辞書オブジェクトのiteritemsメソッドを使うと、キーと要素をセットで取り出しながらループできます。
リストのインデックスの取り方と似ています。
foreachのように使うことができます。
dict = {'foo':'spam', 'bar':'egg', 'baz':'bacon'}
for key, item in dict.iteritems():
print '%s and %s and %s... and %s' % (item, item, key, item)
実行結果
bacon and bacon and baz... and bacon
spam and spam and foo... and spam
egg and egg and bar... and egg
この実行結果からもわかるとおり、取得できる順序は不定です。