extending and embedding python int pysys_setargv(int argcchar **argvsets command-line options used to populate the value of sys argv this should only be called before py_initialize(accessing python from although there are many ways that the interpreter can be accessed from cfour essential tasks are the most common with embeddingn importing python library modules (emulating the import statementn getting references to objects defined in modules calling python functionsclassesand methods accessing the attributes of objects (datamethodsand so onall of these operations can be carried out using these basic operations defined in the python apipyobject *pyimport_importmodule(const char *modnameimports module modname and returns reference to the associated module object pyobject *pyobject_getattrstring(pyobject *objconst char *namegets an attribute from an object this is the same as obj name int pyobject_setattrstring(pyobject *objconst char *namepyobject *valuesets an attribute on an object this is the same as obj name value pyobject *pyeval_callobject(pyobject *funcpyobject *argscalls func with arguments args func is python callable object (functionmethodclassand so onargs is tuple of arguments pyobject pyeval_callobjectwithkeywords(pyobject *funcpyobject *argspyobject *kwargscalls func with positional arguments args and keyword arguments kwargs func is callable objectargs is tupleand kwargs is dictionary the following example illustrates the use of these functions by calling and using various parts of the re module from this program prints out all of the lines read from stdin that contain python regular expression supplied by the user #include "python hint main(int argcchar **argvpyobject *repyobject *re_compilepyobject *patpyobject *pat_searchpyobject *argschar buffer[ ]if (argc ! fprintf(stderr,"usage% pattern\ ",argv[ ])exit( )py_initialize() lib fl ff