Return either the items or viewitems method for a dictionary. Args: d (:obj:`dict`): A dictionary. Returns: view method: Either the items or viewitems method.
(d)
| 6 | |
| 7 | # Dictionary python 2-3 compatibility stuff |
| 8 | def viewitems(d): |
| 9 | """Return either the items or viewitems method for a dictionary. |
| 10 | |
| 11 | Args: |
| 12 | |
| 13 | d (:obj:`dict`): A dictionary. |
| 14 | |
| 15 | Returns: |
| 16 | |
| 17 | view method: Either the items or viewitems method. |
| 18 | |
| 19 | """ |
| 20 | func = getattr(d, "viewitems", None) |
| 21 | if func is None: |
| 22 | func = d.items |
| 23 | return func() |
| 24 | |
| 25 | |
| 26 | def viewkeys(d): |