OLD | NEW |
1 # Unmodified from http://code.activestate.com/recipes/576693/ | 1 # Unmodified from http://code.activestate.com/recipes/576693/ |
2 # other than to add MIT license header (as specified on page, but not in code). | 2 # other than to add MIT license header (as specified on page, but not in code). |
3 # Linked from Python documentation here: | 3 # Linked from Python documentation here: |
4 # http://docs.python.org/2/library/collections.html#collections.OrderedDict | 4 # http://docs.python.org/2/library/collections.html#collections.OrderedDict |
5 # | 5 # |
6 # This should be deleted once Py2.7 is available on all bots, see | 6 # This should be deleted once Py2.7 is available on all bots, see |
7 # http://crbug.com/241769. | 7 # http://crbug.com/241769. |
8 # | 8 # |
9 # Copyright (c) 2009 Raymond Hettinger. | 9 # Copyright (c) 2009 Raymond Hettinger. |
10 # | 10 # |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 def itervalues(self): | 159 def itervalues(self): |
160 'od.itervalues -> an iterator over the values in od' | 160 'od.itervalues -> an iterator over the values in od' |
161 for k in self: | 161 for k in self: |
162 yield self[k] | 162 yield self[k] |
163 | 163 |
164 def iteritems(self): | 164 def iteritems(self): |
165 'od.iteritems -> an iterator over the (key, value) items in od' | 165 'od.iteritems -> an iterator over the (key, value) items in od' |
166 for k in self: | 166 for k in self: |
167 yield (k, self[k]) | 167 yield (k, self[k]) |
168 | 168 |
| 169 # Suppress 'OrderedDict.update: Method has no argument': |
| 170 # pylint: disable=E0211 |
169 def update(*args, **kwds): | 171 def update(*args, **kwds): |
170 '''od.update(E, **F) -> None. Update od from dict/iterable E and F. | 172 '''od.update(E, **F) -> None. Update od from dict/iterable E and F. |
171 | 173 |
172 If E is a dict instance, does: for k in E: od[k] = E[k] | 174 If E is a dict instance, does: for k in E: od[k] = E[k] |
173 If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] | 175 If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] |
174 Or if E is an iterable of items, does: for k, v in E: od[k] = v | 176 Or if E is an iterable of items, does: for k, v in E: od[k] = v |
175 In either case, this is followed by: for k, v in F.items(): od[k] =
v | 177 In either case, this is followed by: for k, v in F.items(): od[k] =
v |
176 | 178 |
177 ''' | 179 ''' |
178 if len(args) > 2: | 180 if len(args) > 2: |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 return KeysView(self) | 280 return KeysView(self) |
279 | 281 |
280 def viewvalues(self): | 282 def viewvalues(self): |
281 "od.viewvalues() -> an object providing a view on od's values" | 283 "od.viewvalues() -> an object providing a view on od's values" |
282 return ValuesView(self) | 284 return ValuesView(self) |
283 | 285 |
284 def viewitems(self): | 286 def viewitems(self): |
285 "od.viewitems() -> a set-like object providing a view on od's items" | 287 "od.viewitems() -> a set-like object providing a view on od's items" |
286 return ItemsView(self) | 288 return ItemsView(self) |
287 | 289 |
OLD | NEW |