I expected the following code to work:

f = file(fn,"wb")
writer = csv.writer(f)
for i in range(IMax):
     writer.writerow([dates[i]].append([ReturnHistories[j][i] for j in
range(N)]))

but instead i got the following error message:
Error: sequence expected

However, if i modify the code to read
writer = csv.writer(f)
for i in range(IMax):
    x = dates[i]
    x.append([ReturnHistories[j][i] for j in range(N)])
     writer.writerow(x)

It works like a charm.

Question: Why does the first form not work?

Thomas Philips

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to