reachy2_sdk.utils.custom_dict
Custom dict module.
Defines a custom dict class to modify repr of dict.
1"""Custom dict module. 2 3Defines a custom dict class to modify repr of dict. 4 5""" 6 7from typing import Any, Generic, TypeVar 8 9K = TypeVar("K", bound=Any) 10V = TypeVar("V", bound=Any) 11 12 13class CustomDict(dict[K, V], Generic[K, V]): 14 """CustomDict is an implementation of dict with a custom __repr__ method, to enhance readability.""" 15 16 def __repr__(self) -> str: 17 """Clean representation of the CustomDict.""" 18 items = ",\n".join(f"'{k}': {v}" for k, v in self.items()) 19 return f"""{{{items}}}"""
class
CustomDict(dict[~K, ~V], typing.Generic[~K, ~V]):
14class CustomDict(dict[K, V], Generic[K, V]): 15 """CustomDict is an implementation of dict with a custom __repr__ method, to enhance readability.""" 16 17 def __repr__(self) -> str: 18 """Clean representation of the CustomDict.""" 19 items = ",\n".join(f"'{k}': {v}" for k, v in self.items()) 20 return f"""{{{items}}}"""
CustomDict is an implementation of dict with a custom __repr__ method, to enhance readability.
Inherited Members
- builtins.dict
- get
- setdefault
- pop
- popitem
- keys
- items
- values
- update
- fromkeys
- clear
- copy