MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __repr__

Method __repr__

cellular_automata/wa_tor.py:77–91  ·  view source on GitHub ↗

>>> Entity(prey=True, coords=(1, 1)) Entity(prey=True, coords=(1, 1), remaining_reproduction_time=5) >>> Entity(prey=False, coords=(2, 1)) # doctest: +NORMALIZE_WHITESPACE Entity(prey=False, coords=(2, 1), remaining_reproduction_time=20, energy_value=15)

(self)

Source from the content-addressed store, hash-verified

75 )
76
77 def __repr__(self) -> str:
78 """
79 >>> Entity(prey=True, coords=(1, 1))
80 Entity(prey=True, coords=(1, 1), remaining_reproduction_time=5)
81 >>> Entity(prey=False, coords=(2, 1)) # doctest: +NORMALIZE_WHITESPACE
82 Entity(prey=False, coords=(2, 1),
83 remaining_reproduction_time=20, energy_value=15)
84 """
85 repr_ = (
86 f"Entity(prey={self.prey}, coords={self.coords}, "
87 f"remaining_reproduction_time={self.remaining_reproduction_time}"
88 )
89 if self.energy_value is not None:
90 repr_ += f", energy_value={self.energy_value}"
91 return f"{repr_})"
92
93
94class WaTor:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected