当前位置: 首页>>代码示例>>Python>>正文


Python MutableMapping.update方法代码示例

本文整理汇总了Python中collections.MutableMapping.update方法的典型用法代码示例。如果您正苦于以下问题:Python MutableMapping.update方法的具体用法?Python MutableMapping.update怎么用?Python MutableMapping.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在collections.MutableMapping的用法示例。


在下文中一共展示了MutableMapping.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import update [as 别名]
    def update(self, *args, **kwargs):

        if len(args) > 1:
            raise TypeError("update() takes at most 1 positional "
                            "arguments ({} given)".format(len(args)))
        if len(args) >= 1:
            other = args[0]
            if isinstance(other, KeyedList):
                # Merge
                for key, value in other.all_items():
                    self[key] = value
            else:
                MutableMapping.update(self, other)

        for key, value in kwargs.items():
            if isinstance(value, KeyedList):
                try:
                    subkl = self[key]
                except KeyError:
                    subkl = KeyedList()
                    self[key] = subkl
                else:
                    if not isinstance(subkl, KeyedList):
                        raise KeyError('target key "%s" is a value, cannot '
                                'update value against another keyed list' %
                                (key,))
                subkl.update(value)
            else:
                self[key] = value
开发者ID:selvendran-varathan,项目名称:python-development,代码行数:31,代码来源:keyedlist.py

示例2: update

# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import update [as 别名]
    def update(*args, **kwds):
        self = args[0]

        with FastInserter(self.cursor):
            MutableMapping.update(*args, **kwds)
            # make table and index stored contiguously
            self.cursor.execute("VACUUM")
开发者ID:3D-e-Chem,项目名称:kripodb,代码行数:9,代码来源:db.py

示例3: update

# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import update [as 别名]
 def update(self, *args, **kw):
     if args:
         lst = args[0]
         if len(lst) != len(dict(lst)):
             # this does not catch the cases where we overwrite existing
             # keys, but those would produce too many warning
             msg = ("Behavior of MultiDict.update() has changed "
                 "and overwrites duplicate keys. Consider using .extend()"
             )
             warnings.warn(msg, UserWarning, stacklevel=2)
     MutableMapping.update(self, *args, **kw)
开发者ID:5m0k3r,项目名称:desarrollo_web_udp,代码行数:13,代码来源:multidict.py

示例4: __init__

# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import update [as 别名]
 def __init__(*args, **kwargs):
     if not args:
         raise TypeError("OrderedDict.__init__() needs an instance as the first argument")
     self = args[0]
     args = args[1:]
     if len(args) > 1:
         raise TypeError("OrderedDict() takes at most 1 positional argument, got %d" % len(args))
     dict.__init__(self)
     if not self:
         self._keys = []
     MutableMapping.update(self, *args, **kwargs)
开发者ID:dmitryTsatsarin,项目名称:schematics,代码行数:13,代码来源:datastructures.py


注:本文中的collections.MutableMapping.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。