Is this an instance of namedtuple/NamedTuple? From: https://stackoverflow.com/a/62692640 Args: obj (object): An object. Returns: bool: True if namedtuple/NamedTuple else False.
(obj: object)
| 23 | |
| 24 | |
| 25 | def isinstance_namedtuple(obj: object) -> bool: |
| 26 | """ |
| 27 | Is this an instance of namedtuple/NamedTuple? |
| 28 | From: https://stackoverflow.com/a/62692640 |
| 29 | |
| 30 | Args: |
| 31 | obj (object): An object. |
| 32 | |
| 33 | Returns: |
| 34 | bool: True if namedtuple/NamedTuple else False. |
| 35 | """ |
| 36 | return isinstance(obj, tuple) and hasattr(obj, '_asdict') and hasattr(obj, '_fields') |
| 37 | |
| 38 | |
| 39 | # ensure we only warn once, otherwise every iteration will trigger a warning |
no outgoing calls
no test coverage detected