Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Have you considered using lists of lists?

list_of_np = []
for i in range(10):
   list[i] = my_np_array()

or even, using list comprehensions,

list_of_np = [my_np_array() for i in range(10)]

If you are really determined to have dynamically generated variable names, Python allows you to modify the current module scope via the globals() call. You can do

for i in range(10):
  globals()["list_number_" + str(i)] = my_np_array()

However in my opinion you'd better stick with one of the two previous forms.