(v)
Figuring out if an object is a named tuple is not as trivial as one may expect
Figuring out if an object is a named tuple is not as trivial as one may expect
Figuring out if an object is a named tuple is not as trivial as one may expect
def is_namedtuple(v) -> bool:
    """Figuring out if an object is a named tuple is not as trivial as one may expect"""
    try:
        return isinstance(v, tuple) and hasattr(v, "_fields")
    except TypeError:
        return False
def is_namedtuple ( v ) -> bool : try : return isinstance ( v , tuple ) and hasattr ( v , "_fields" ) except TypeError : return False