本文整理匯總了Python中collections.MutableMapping.pop方法的典型用法代碼示例。如果您正苦於以下問題:Python MutableMapping.pop方法的具體用法?Python MutableMapping.pop怎麽用?Python MutableMapping.pop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類collections.MutableMapping
的用法示例。
在下文中一共展示了MutableMapping.pop方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __delitem__
# 需要導入模塊: from collections import MutableMapping [as 別名]
# 或者: from collections.MutableMapping import pop [as 別名]
def __delitem__(self, key):
dict.__delitem__(self, key)
key, prev, next = self.__map.pop(key)
prev[2] = next
next[1] = prev
示例2: popitem
# 需要導入模塊: from collections import MutableMapping [as 別名]
# 或者: from collections.MutableMapping import pop [as 別名]
def popitem(self, last=True):
if not self:
raise KeyError('dictionary is empty')
if last:
key = next(reversed(self))
else:
key = next(iter(self))
value = self.pop(key)
return key, value
示例3: __delitem__
# 需要導入模塊: from collections import MutableMapping [as 別名]
# 或者: from collections.MutableMapping import pop [as 別名]
def __delitem__(self, key, PREV=0, NEXT=1, dict_delitem=dict.__delitem__):
'od.__delitem__(y) <==> del od[y]'
# Deleting an existing item uses self.__map to find the link which is
# then removed by updating the links in the predecessor and successor nodes.
if key in self:
key = self.__lower.pop(key.lower())
dict_delitem(self, key)
link = self.__map.pop(key)
link_prev = link[PREV]
link_next = link[NEXT]
link_prev[NEXT] = link_next
link_next[PREV] = link_prev
示例4: popitem
# 需要導入模塊: from collections import MutableMapping [as 別名]
# 或者: from collections.MutableMapping import pop [as 別名]
def popitem(self, last=True):
'''od.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.
'''
if not self:
raise KeyError('dictionary is empty')
key = next(reversed(self) if last else iter(self))
value = self.pop(key)
return key, value
示例5: __delitem__
# 需要導入模塊: from collections import MutableMapping [as 別名]
# 或者: from collections.MutableMapping import pop [as 別名]
def __delitem__(self, key):
dict.__delitem__(self, key)
key, prev, next = self.__map.pop(key)
prev[2] = next
next[1] = prev
示例6: popitem
# 需要導入模塊: from collections import MutableMapping [as 別名]
# 或者: from collections.MutableMapping import pop [as 別名]
def popitem(self, last=True):
if not self:
raise KeyError('dictionary is empty')
if last:
key = next(reversed(self))
else:
key = next(iter(self))
value = self.pop(key)
return key, value
示例7: popitem
# 需要導入模塊: from collections import MutableMapping [as 別名]
# 或者: from collections.MutableMapping import pop [as 別名]
def popitem(self):
if not self:
raise KeyError
key = self._keys.pop()
value = dict.pop(self, key)
return key, value
示例8: __reduce__
# 需要導入模塊: from collections import MutableMapping [as 別名]
# 或者: from collections.MutableMapping import pop [as 別名]
def __reduce__(self):
items = [[k, self[k]] for k in self]
inst_dict = vars(self).copy()
inst_dict.pop('_keys', None)
return self.__class__, (items,), inst_dict
# Methods with indirect access via the above methods