I wonder if it possible to use eval to creates class data attributes. Something like following code:
class Test:
def __init(self):
matrix_names = ['F', 'B', 'H', 'Q', 'R', 'x', 'P']
for matrix in matrix_names:
print matrix
operation = "self.%s = self.__matrix_read(%s)" %\
(matrix, matrix)
eval(operation)
def __matrix_read(self, filename):
return (read(".matrix/%s.csv"%filename))
In iPython I get:
File "<string>", line 1
self.F = self.__matrix_read(F)
^
SyntaxError: invalid syntax