Return either the keys or viewkeys method for a dictionary. Args: d (:obj:`dict`): A dictionary. Returns: view method: Either the keys or viewkeys method.
(d)
| 24 | |
| 25 | |
| 26 | def viewkeys(d): |
| 27 | """Return either the keys or viewkeys method for a dictionary. |
| 28 | |
| 29 | Args: |
| 30 | |
| 31 | d (:obj:`dict`): A dictionary. |
| 32 | |
| 33 | Returns: |
| 34 | |
| 35 | view method: Either the keys or viewkeys method. |
| 36 | |
| 37 | """ |
| 38 | func = getattr(d, "viewkeys", None) |
| 39 | if func is None: |
| 40 | func = d.keys |
| 41 | return func() |
| 42 | |
| 43 | |
| 44 | def viewvalues(d): |
no test coverage detected