GroupDict

class deepfos.lib.utils.GroupDict(group, **kwargs)

传入唯一键名集合group,在新增字典的键名已存在在group中时,raise KeyError

>>> shared_key_group = Group()
>>> a = GroupDict(shared_key_group)
>>> b = GroupDict(shared_key_group)
>>> a['a'] = 1
>>> a,b
({'a': 1}, {})
>>> b['a'] = 2
Traceback (most recent call last):
  ...
KeyError: 'Key a has been existed in key_group. Cannot be added to current dict.'
>>> a['a'] = 'a'
>>> a
{'a': 'a'}
Exclude-members

传入唯一键名集合group,在新增字典的键名已存在在group中时,raise KeyError

>>> shared_key_group = Group()
>>> a = GroupDict(shared_key_group)
>>> b = GroupDict(shared_key_group)
>>> a['a'] = 1
>>> a,b
({'a': 1}, {})
>>> b['a'] = 2
Traceback (most recent call last):
  ...
KeyError: 'Key a has been existed in key_group. Cannot be added to current dict.'
>>> a['a'] = 'a'
>>> a
{'a': 'a'}
See Also:

get_groupdicts