本文整理汇总了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