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

Method __repr__

data_structures/binary_tree/red_black_tree.py:487–500  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

485 yield self.label
486
487 def __repr__(self) -> str:
488 from pprint import pformat
489
490 if self.left is None and self.right is None:
491 return f"'{self.label} {(self.color and 'red') or 'blk'}'"
492 return pformat(
493 {
494 f"{self.label} {(self.color and 'red') or 'blk'}": (
495 self.left,
496 self.right,
497 )
498 },
499 indent=1,
500 )
501
502 def __eq__(self, other: object) -> bool:
503 """Test if two trees are equal."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected