block matching python script