Python- how to get list of self variables in a class consist of N-self

China☆狼群 提交于 2019-12-02 13:15:30

Here's my interpretation of your problem: You're creating a MoneyModel object which contains a collection of MoneyAgent objects stored in a collection-like object referred to as MoneyModel.schedule, and you want a list of the names of each MoneyAgent object within your MoneyModel.schedule collection.

Assuming MoneyModel.schedule behaves as an iterable object, the following should work:

atr = [agent.name for agent in gow.schedule]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!