I need to use some float-type variables for two purposes: 1. To use it`s values for calculation of some function, 2. To change the values of these variables theirselves. I know how to do it generally, but I need to have simple short notation for my float-type variables. In the trivial example below I add two numbers, and my aim is to be able to write smth like 'f(a, i)' instead of 'a.vals[a.define_index[i]]' in the example below. I need to write simple notation both from left of '=' and from right of '=':
import numpy as np
class SomeClass(object):
def __init__(self):
self.vals=np.ones(10)
self.define_index=[]
for i in range(10):
self.define_index.append(10-1-i)
a=SomeClass()
for i in range(10):
a.vals[a.define_index[i]]=a.vals[a.define_index[i]]+1
print('sums =', a.vals)