I want to run a function over a loop and I want to store the outputs in different files, such that the filename contains the loop variable. Here is an example
for i in xrange(10):
f = open("file_i.dat",'w')
f.write(str(func(i))
f.close()
How can I do it in python?