def is_parfile(fn):
 PAR_ID = 'PAR2\x00PKT'
 try:
  with open(fn, 'rb') as f:
   buf = f.read(8)
   return buf.startswith(PAR_ID)
 except:
  pass
 return False

def is_parfile ( fn ) : PAR_ID = 'PAR2\x00PKT' try : with open ( fn , 'rb' ) as f : buf = f . read ( 8 ) return buf . startswith ( PAR_ID ) except : pass return False
check quickly whether file has par2 signature .