def is_gzip(fp):
 return (open(fp, 'rb').read(2) == '\x1f\x8b')

def is_gzip ( fp ) : return ( open ( fp , 'rb' ) . read ( 2 ) == '\x1f\x8b' )
checks the first two bytes of the file for the gzip magic number if the first two bytes of the file are 1f 8b .