本文整理匯總了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)