modify pattern match, first match takes priority,add python surpport