def is_tarfile(name):
 try:
  t = open(name)
  t.close()
  return True
 except TarError:
  return False

def is_tarfile ( name ) : try : t = open ( name ) t . close ( ) return True except TarError : return False
returns if the path belongs to a tarfile or not .