Pythonic / itertools way to go through a dict?
- by dmd
def reportCSV(t):
ret = ''
for ev in t:
for p in t[ev]:
for w in t[ev][p]:
ret += ','.join((ev, p, w, t[ev][p][w])) + '\n'
return ret
What is a more pythonic way to do this, e.g. using itertools or the like?
In this case I'm just writing it out to a CSV file.
t is a dict
t[ev] is a dict
t[ev][p]…