/import re *re pyimport_importmodule("re")/pat re compile(pat,flags*re_compile pyobject_getattrstring(re,"compile")args py_buildvalue("( )"argv[ ])pat pyeval_callobject(re_compileargs)py_decref(args)/pat_search pat search bound method*pat_search pyobject_getattrstring(pat,"search")/read lines and perform matches *while (fgets(buffer, ,stdin)pyobject *matchargs py_buildvalue("( )"buffer)/match pat search(buffer*match pyeval_callobject(pat_search,args)py_decref(args)if (match !py_noneprintf("% ",buffer)py_xdecref(match)py_decref(pat)py_decref(re_compile)py_decref(re)py_finalize()return in any embedding codeit is critically important to properly manage reference counts in particularyou will need to decrease the reference count on any objects created from or returned to as result of evaluating functions converting python objects to major problem with embedded use of the interpreter is converting the result of python function or method call into suitable representation as general ruleyou need to know in advance exactly what kind of data an operation is going to return sadlythere is no high-level convenience function like pyarg_parsetuple(for converting single object value howeverthe following lists some low-level conversion functions that will convert few primitive python data types into an appropriate representation as long as you know exactly what kind of python object you are working withpython-to- conversion functions long pyint_aslong(pyobject *long pylong_aslong(pyobject *double pyfloat_asdouble(pyobject *char *pystring_asstring(pyobject *(python onlychar *pybytes_asstring(pyobject *(python onlyfor any types more complicated than thisyou will need to consult the api documentation ( lib fl ff