def __init__(self, name, mapping):
if type(mapping) is not dict: # we really only want dict literals
raise ValueError()
if type(name) is not str:
raise ValueError()
for key in mapping:
self._validate_member_(key)
for value in mapping.values():
self._validate_member_(value)
# Read only proxy of mapping, mutation to `mapping` will be reflected
# but there isn't much we can do about that. Good use of this object
# would involve a dict literal anyway.
self.mapping = types.MappingProxyType(mapping)
super().__init__(name)
评论列表
文章目录