diff options
author | Mariatta Wijaya <mariatta.wijaya@gmail.com> | 2017-02-06 20:18:39 -0800 |
---|---|---|
committer | Mariatta Wijaya <mariatta.wijaya@gmail.com> | 2017-02-06 20:18:39 -0800 |
commit | 731cca110f376cdbaffb536e42d6c9d6da574fa8 (patch) | |
tree | 9cb95caf6f8b933115820bf699725d9cd600d2df /Lib/collections/__init__.py | |
parent | da79bcf8ac7ae72218ab023e1ed54390bc1a3a27 (diff) | |
parent | c8102f4d974669f4c5e4ca7bcd73292a1ac5bcbf (diff) | |
download | cpython-731cca110f376cdbaffb536e42d6c9d6da574fa8.tar.gz |
Issue #29371: merge with 3.6
Diffstat (limited to 'Lib/collections/__init__.py')
-rw-r--r-- | Lib/collections/__init__.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 85b4c3c19a..8408255d27 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -157,9 +157,9 @@ class OrderedDict(dict): dict.clear(self) 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. + '''Remove and return a (key, value) pair from the dictionary. + Pairs are returned in LIFO order if last is true or FIFO order if false. ''' if not self: raise KeyError('dictionary is empty') @@ -180,11 +180,9 @@ class OrderedDict(dict): return key, value def move_to_end(self, key, last=True): - '''Move an existing element to the end (or beginning if last==False). - - Raises KeyError if the element does not exist. - When last=True, acts like a fast version of self[key]=self.pop(key). + '''Move an existing element to the end (or beginning if last is false). + Raise KeyError if the element does not exist. ''' link = self.__map[key] link_prev = link.prev @@ -248,7 +246,10 @@ class OrderedDict(dict): return default def setdefault(self, key, default=None): - 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od' + '''Insert key with a value of default if key is not in the dictionary. + + Return the value for key if key is in the dictionary, else default. + ''' if key in self: return self[key] self[key] = default @@ -274,9 +275,7 @@ class OrderedDict(dict): @classmethod def fromkeys(cls, iterable, value=None): - '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S. - If not specified, the value defaults to None. - + '''Create a new ordered dictionary with keys from iterable and values set to value. ''' self = cls() for key in iterable: |