我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用UserDict.DictMixin.update()。
def __init__(self, data=None): self.data = set() def _remove(item, selfref=ref(self)): self = selfref() if self is not None: if self._iterating: self._pending_removals.append(item) else: self.data.discard(item) self._remove = _remove # A list of keys to be removed self._pending_removals = [] self._iterating = set() if data is not None: self.update(data)
def read(self, *files, **params): """ Read and parse INI files. :param *files: Files for reading :param **params: Params for parsing Set `update=False` for prevent values redefinition. """ for f in files: try: with io.open(f, encoding='utf-8') as ff: NS_LOGGER.info('Read from `{0}`'.format(ff.name)) self.parse(ff.read(), **params) except (IOError, TypeError, SyntaxError, io.UnsupportedOperation): if not self.silent_read: NS_LOGGER.error('Reading error `{0}`'.format(ff.name)) raise
def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) try: self.__end except AttributeError: self.clear() self.update(*args, **kwds)
def __init__(self, *args, **kwds): """ A dictionary which maintains the insertion order of keys. """ if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) try: self.__end except AttributeError: self.clear() self.update(*args, **kwds)
def update(self, other): if self._pending_removals: self._commit_removals() if isinstance(other, self.__class__): self.data.update(other.data) else: for element in other: self.add(element)
def __ior__(self, other): self.update(other) return self # Helper functions for simple delegating methods.
def __init__(self, iterable=()): self._items = [] self.update(iterable)
def update(self, other): for item in other: self.add(item)