Python- How To Get List Of Self Variables In A Class Consist Of N-self
Edited: I want to generate N-number of agents. Each agent will have a name, so I create a random name from names and assigned it to class Agent. After I run the model, I want to ge
Solution 1:
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 name
s 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]
Post a Comment for "Python- How To Get List Of Self Variables In A Class Consist Of N-self"