本文整理汇总了Python中mydict.Dict.update方法的典型用法代码示例。如果您正苦于以下问题:Python Dict.update方法的具体用法?Python Dict.update怎么用?Python Dict.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mydict.Dict
的用法示例。
在下文中一共展示了Dict.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from mydict import Dict [as 别名]
# 或者: from mydict.Dict import update [as 别名]
def update(self,d,strict=True):
"""Update current values with the specified settings
Returns the sanitized update values.
"""
ok = self.checkDict(d,strict)
Dict.update(self,ok)
示例2: update
# 需要导入模块: from mydict import Dict [as 别名]
# 或者: from mydict.Dict import update [as 别名]
def update(self, data={}, name=None, removeLocals=False):
"""Add a dictionary to the Config object.
The data, if specified, should be a valid Python dict.
If no name is specified, the data are added to the top dictionary
and will become attributes.
If a name is specified, the data are added to the named attribute,
which should be a dictionary. If the name does not specify a
dictionary, an empty one is created, deleting the existing attribute.
If a name is specified, but no data, the effect is to add a new
empty dictionary (section) with that name.
If removeLocals is set, keys starting with '_' are removed from the
data before updating the dictionary and not
included in the config. This behaviour can be changed by setting
removeLocals to false.
"""
if removeLocals:
for k in data.keys():
if k[0] == "_":
del data[k]
if name:
if not self.has_key(name) or not isinstance(self[name], dict):
self[name] = Dict()
self[name].update(data)
else:
Dict.update(self, data)