Ticket #4546: datastructures.py.diff
File datastructures.py.diff, 798 bytes (added by , 17 years ago) |
---|
-
datastructures.py
98 98 obj = self.__class__(self) 99 99 obj.keyOrder = self.keyOrder 100 100 return obj 101 102 def popitem(self): 103 "Return first inserted (key, value) pair" 104 if len(self.keyOrder) == 0: 105 raise KeyError, 'popitem(): dictionary is empty' 106 key = self.keyOrder[0] 107 value = self[key] 108 self.__delitem__(key) 109 return (key, value) 110 111 def pop(self, key, default=None): 112 if default is None: 113 value = self[key] 114 else: 115 value = self.get(key, default) 116 if self.has_key(key): 117 self.__delitem__(key) 118 return value 119 101 120 102 121 def __repr__(self): 103 122 """