(name)
Return True if name points to a tar archive that we
       are able to handle, else return False.

       'name' should be a string, file, or file-like object.
Return True if name points to a tar archive that we
       are able to handle, else return False.
Return True if name points to a tar archive that we are able to handle else return False .
def is_tarfile(name):
    """Return True if name points to a tar archive that we
       are able to handle, else return False.

       'name' should be a string, file, or file-like object.
    """
    try:
        if hasattr(name, "read"):
            t = open(fileobj=name)
        else:
            t = open(name)
        t.close()
        return True
    except TarError:
        return False
def is_tarfile ( name ) : try : if hasattr ( name , "read" ) : t = open ( fileobj = name ) else : t = open ( name ) t . close ( ) return True except TarError : return False