これをネストされたforループをよりpythonicにする方法を探しています。具体的には、3つの変数の一意の組み合わせを反復処理し、データが辞書に存在する場合はファイルに書き込むにはどうすればよいですか?
foo,bar = {},{} #filling of dicts not shown
with open(someFile,'w') as aFile:
for year in years:
for state in states:
for county in counties:
try:foo[year,state,county],bar[state,county]
except:continue
aFile.write("content"+"\n")