I am trying to create my own Nbody simulation from scratch. I have created a class (called Body) that contains functions to calculate the forces from the other bodies and move it accordingly.
I have created another class, called System, that defines the number of bodies, controls the updates of the positions and updates a plot of the system.
Both classes work fine if I define the number of variables individually like this:
d1 = Body(i)
d2 = Body(i)
list = [d1,d2, ...]
self.liste = 
for i in range(n):
[None, None, None, ....]
The following works for me:
class Body: bodies =  def __init__(self, n): self.n = n def __str__(self): return str(self.n) for i in range(5): Body.bodies.append(Body(i)) for body in Body.bodies: print body # This also works. print body.n
Note that if you directly try and print a class, you need a