I am building a physics engine in python, and am trying to make a function, preferably a generator, which makes a defined number of variables with systematically assigned names in the self-defined class "particle."
But to do so, I need to alter the variable name with each iteration, for which I need to alter the code in the function itself, which is hard to find tutorials of.
My target is something along the lines of
def gen_parts(part_amount, basename, mass, charge):
counter_2 = 0
while counter_2 < part_amount:
#generate position and velocity: v = [v_x, v_y] and s = [s_x, s_y]
name = basename+"_"+str(counter)
code(name) = GenPart(counter, s, v, mass, charge) #I need the code() function from here, somehow
counter += 1
How can I do this?