from typing import Dict
class MyDict():
def __init__(self, data: Dict[str, str] = {}):
self._data = data
def __str__(self) -> str:
return str(self._data)
def update(self, component: Dict[str, str]):
return self._data.update(component)
if __name__ == "__main__":
myd0 = MyDict()
myd0.update_a({"test0": "hoge"})
myd1 = MyDict()
myd1.update_a({"test1": "hoge"})
print(myd0)
print(myd1)
{'test0': 'hoge'}
{'test0': 'hoge', 'test1': 'hoge'}
class MyDict():
def __init__(self, data: Dict[str, str] = None):
self._data = data if data is not None else {}