I am looking at source code of mesa, and I see this pattern constantly shows up
def place_agent(self, agent, pos):
""" Position an agent on the grid, and set its pos variable. """
self._place_agent(pos, agent)
agent.pos = pos
def _place_agent(self, pos, agent):
""" Place the agent at the correct location. """
x, y = pos
self.grid[x][y] = agent
if pos in self.empties:
self.empties.remove(pos)
Why should we have a separate private method? Especially when there is not real "private" method in python and in both methods we write new values. Is it some kind of design pattern?
Aucun commentaire:
Enregistrer un commentaire