| 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.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.