I wonder if there is a way to generate new variables and its assaignment based on a particular global variable.
I have the following code which belongs to a larger code function. In this particular case:
VNF_TYPES = 2
# Sum up vnf event per type in transitioned state
total_vnf = [0]*VNF_TYPES
for event in states[key][0]:
total_vnf[0] += event[0]
total_vnf[1] += event[1]
If I change the value of:
VNF_TYPES = 4
Is there a way to automatically generate new variables and its assaignments in such a way that it results in:
# Sum up vnf event per type in transitioned state
total_vnf = [0]*VNF_TYPES
for event in states[key][0]:
total_vnf[0] += event[0]
total_vnf[1] += event[1]
total_vnf[2] += event[2] # automatically generated
total_vnf[3] += event[3] # automatically generated