Python collections.MutableMapping.pop() Examples

The following are 10 code examples of collections.MutableMapping.pop(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module collections.MutableMapping , or try the search function .
Example #1
Source File: python2x.py    From D-VAE with MIT License 5 votes vote down vote up
def __delitem__(self, key):
            dict.__delitem__(self, key)
            key, prev, next = self.__map.pop(key)
            prev[2] = next
            next[1] = prev 
Example #2
Source File: python2x.py    From D-VAE with MIT License 5 votes vote down vote up
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 
Example #3
Source File: python2x.py    From attention-lvcsr with MIT License 5 votes vote down vote up
def __delitem__(self, key):
            dict.__delitem__(self, key)
            key, prev, next = self.__map.pop(key)
            prev[2] = next
            next[1] = prev 
Example #4
Source File: python2x.py    From attention-lvcsr with MIT License 5 votes vote down vote up
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 
Example #5
Source File: util.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #6
Source File: util.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #7
Source File: ordereddict.py    From maltrail with MIT License 5 votes vote down vote up
def __delitem__(self, key):
        dict.__delitem__(self, key)
        key, prev, next = self.__map.pop(key)
        prev[2] = next
        next[1] = prev 
Example #8
Source File: ordereddict.py    From maltrail with MIT License 5 votes vote down vote up
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 
Example #9
Source File: _utils.py    From Tautulli with GNU General Public License v3.0 5 votes vote down vote up
def popitem(self):
                    if not self:
                        raise KeyError
                    key = self._keys.pop()
                    value = dict.pop(self, key)
                    return key, value 
Example #10
Source File: _utils.py    From Tautulli with GNU General Public License v3.0 5 votes vote down vote up
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