(t)
Figuring out if a type is a named tuple is not as trivial as one may expect
Figuring out if a type is a named tuple is not as trivial as one may expect
Figuring out if a type is a named tuple is not as trivial as one may expect
def type_is_namedtuple(t) -> bool:
    """Figuring out if a type is a named tuple is not as trivial as one may expect"""
    try:
        return issubclass(t, tuple) and hasattr(t, "_fields")
    except TypeError:
        return False
def type_is_namedtuple ( t ) -> bool : try : return issubclass ( t , tuple ) and hasattr ( t , "_fields" ) except TypeError : return False