1

I would like to assign some value in incremental parameter name by for loop but there are some error to recognize the parameter name as below.

for i in range(1,4):
    print i
    Name_i = h5py.File(filename_BS_i, "r")

What I expect,

1st for loop Name_1 = h5py.File(filename_1, "r")

2nd for loop Name_2 = h5py.File(filename_2, "r") . .

Do you have any idea.?

I know, it works if I change parameter i_Name instead of Name_i

Thanks!

1 Answers1

0

Consider using a dictionary. e.g.

Names = {} for i in range(1,4): Names[i] = h5py.File(filename_BS_ + str(i), "r")

Jason Stein
  • 714
  • 3
  • 10