def __missing__(self: 'lazydict', key: Hashable) -> Any:
"""Attempts to construct the value and inserts it into the dictionary."""
if self.value_factory is None:
raise KeyError(key)
value = self.value_factory(key)
self[key] = value
return value
评论列表
文章目录