od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.
(self, key, default=__marker)
| 244 | __marker = object() |
| 245 | |
| 246 | def pop(self, key, default=__marker): |
| 247 | '''od.pop(k[,d]) -> v, remove specified key and return the corresponding |
| 248 | value. If key is not found, d is returned if given, otherwise KeyError |
| 249 | is raised. |
| 250 | |
| 251 | ''' |
| 252 | marker = self.__marker |
| 253 | result = dict.pop(self, key, marker) |
| 254 | if result is not marker: |
| 255 | # The same as in __delitem__(). |
| 256 | link = self.__map.pop(key) |
| 257 | link_prev = link.prev |
| 258 | link_next = link.next |
| 259 | link_prev.next = link_next |
| 260 | link_next.prev = link_prev |
| 261 | link.prev = None |
| 262 | link.next = None |
| 263 | return result |
| 264 | if default is marker: |
| 265 | raise KeyError(key) |
| 266 | return default |
| 267 | |
| 268 | def setdefault(self, key, default=None): |
| 269 | '''Insert key with a value of default if key is not in the dictionary. |