[python] Python extract pattern matches