到模塊我有一個主文件可以說main.py
在哪裏產生的對象(機構)名單:如何傳遞對象作爲全局變量列表在python
bodies = [body.Body(
number = i,
length = 1.,
mass = 10.,
mass_moment_of_inertia = 1.,
theta = 0.,
omega = 0.,
xy_force_vector = np.array([0., 0.]),
xy_u_F_vector = np.array([0., 0.]),
ground = 0,
limit_x = 0.,
limit_y = 0.,
z_moment = 0.,
stiffness_coef = 0.,
damping_coef = 0.)
for i in range(0, N)]
我想使用屬性(多個)子文件/模塊中的對象(實體)列表來計算所需的值。我有一個具有模塊submodule.py: submodule.py
def fun_name():
for i in range(0, N):
# joins mass of all objects in one array (this is just an example, I have to to more calculations with the object properties)
q = bodies[i].mass.append()
return q
謝謝大家的幫助。現在我必須考慮什麼是我的問題的最佳解決方案。再次感謝! – avstenit