diff options
author | Raymond Hettinger <python@rcn.com> | 2009-03-19 19:59:58 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-03-19 19:59:58 +0000 |
commit | 2412299be96bf590b46d7b0784cdb620170a8d7a (patch) | |
tree | fb440a9fef80b259b8866a314b4d447ccd4e0619 /Lib/collections.py | |
parent | a0b8d9ad2da71658ce20448bbb3f081bcd39f446 (diff) | |
download | cpython-git-2412299be96bf590b46d7b0784cdb620170a8d7a.tar.gz |
* Add clearer comment to initialization code.
* Add optional argument to popitem() -- modeled
after Anthon van der Neut's C version.
* Fix method markup in docs.
Diffstat (limited to 'Lib/collections.py')
-rw-r--r-- | Lib/collections.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index 1193ebf1b2..8c0b4265f4 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -30,7 +30,7 @@ class OrderedDict(dict, MutableMapping): def clear(self): self.__end = end = [] - end += [None, end, end] # null entry + end += [None, end, end] # sentinel node for doubly linked list self.__map = {} # key --> [key, prev, next] dict.clear(self) @@ -61,10 +61,10 @@ class OrderedDict(dict, MutableMapping): yield curr[0] curr = curr[1] - def popitem(self): + def popitem(self, last=True): if not self: raise KeyError('dictionary is empty') - key = next(reversed(self)) + key = next(reversed(self)) if last else next(iter(self)) value = self.pop(key) return key, value |