本文整理汇总了Python中collections.MutableMapping.values方法的典型用法代码示例。如果您正苦于以下问题:Python MutableMapping.values方法的具体用法?Python MutableMapping.values怎么用?Python MutableMapping.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collections.MutableMapping
的用法示例。
在下文中一共展示了MutableMapping.values方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __repr__
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import values [as 别名]
def __repr__(self):
if not self:
return '%s()' % self.__class__.__name__
try:
items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
return '%s({%s})' % (self.__class__.__name__, items)
except TypeError:
# handle case where values are not orderable
return '{0}({1!r})'.format(self.__class__.__name__, dict(self))
# Multiset-style mathematical operations discussed in:
# Knuth TAOCP Volume II section 4.6.3 exercise 19
# and at http://en.wikipedia.org/wiki/Multiset
#
# Outputs guaranteed to only include positive counts.
#
# To strip negative and zero counts, add-in an empty counter:
# c += Counter()
示例2: clear
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import values [as 别名]
def clear(self):
with self.lock:
# Copy pointers to all values, then wipe the mapping
values = list(itervalues(self._container))
self._container.clear()
if self.dispose_func:
for value in values:
self.dispose_func(value)
示例3: getlist
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import values [as 别名]
def getlist(self, key):
"""Returns a list of all the values for the named field. Returns an
empty list if the key doesn't exist."""
try:
vals = _dict_getitem(self, key.lower())
except KeyError:
return []
else:
if isinstance(vals, tuple):
return [vals[1]]
else:
return vals[1:]
# Backwards compatibility for httplib
示例4: __delitem__
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import values [as 别名]
def __delitem__(self, elem):
'Like dict.__delitem__() but does not raise KeyError for missing values.'
if elem in self:
super(Counter, self).__delitem__(elem)
示例5: __len__
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import values [as 别名]
def __len__(self):
return len(set().union(*self.maps)) # reuses stored hash values if possible
示例6: __delitem__
# 需要导入模块: from collections import MutableMapping [as 别名]
# 或者: from collections.MutableMapping import values [as 别名]
def __delitem__(self, elem):
'''Like dict.__delitem__() but does not raise KeyError for
missing values.'''
if elem in self:
dict.__delitem__(self, elem)