On Mon, Jun 4, 2012 at 6:21 PM, FSH <lee.joos...@gmail.com> wrote:
> Hello,
>
> I have a simple question. I wish to generate an array of file
> pointers. For example, I have files:
>
> data1.txt
> data2.txt
> data3.txt
> ....
>
> I wish to generate fine pointer array so that I can read the files at
> the same time.
>
> for index in range(N):
>     fid[index] = open('data%d.txt' % index,'r')

That loop will start at 0, not 1, so so you'll try to open "data0.txt".
To rectify that, use range(1, N+1), though you'll then need to use a
list comprehension like Ben Finney demonstrated.

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to