Hello,
I need to access variables given their names, in the following way:
a = numpy.array([1,2,3])
b = numpy.array([4,5,6])
names = ('a', 'b')
Then, I pass the variable names
to a function, say numpy.hstack() to obtain the same result as with numpy.hstack((a,b))
.
What is the best pythonic way to do so?
And what is the purpose? I have a function, that accepts names of numpy arrays and stacks the related arrays (defined in the function) together to process them. I need to create all possible combinations of these arrays, hence:
- A combination (tuple) of array names is created.
- The combination (tuple) is passed to a function as an argument.
- The function concatenates related arrays and processes the result.
Hopefully this question is not too cryptic. Thanks for responses in advance :-)