namespace to serve as input for python print statement string because the string execution call in this version lets you specify namespacesyou can better partition the embedded code your system runs--each grouping can have distinct namespace to avoid overwriting other groupsvariables and because this call returns resultyou can better communicate with the embedded codeexpression results are outputsand assignments to globals in the namespace in which code runs can serve as inputs before we move oni need to explain three coding issues here firstthis program also decrements the reference count on objects passed to it from pythonusing the py_decref call described in python' api manuals these calls are not strictly needed here (the objectsspace is reclaimed when the programs exits anyhow)but they demonstrate how embedding interfaces must manage reference counts when python passes object ownership to if this was function called from larger systemfor instanceyou would generally want to decrement the count to allow python to reclaim the objects secondin realistic programyou should generally test the return values of all the api calls in this program immediately to detect errors ( import failureerror tests are omitted in this section' example to keep the code simplebut they should be included in your programs to make them more robust and thirdthere is related function that lets you run entire files of codebut it is not demonstrated in this pyrun_file because you can always load file' text and run it as single code string with pyrun_stringthe pyrun_file call' main advantage is to avoid allocating memory for file content in such multiline code stringsthe \ character terminates lines and indentation group blocks as usual calling python objects the last two sections dealt with running strings of codebut it' easy for programs to deal in terms of python objectstoo example - accomplishes the same task as examples - and - but it uses other api tools to interact with objects in the python module directlypyimport_importmodule imports the module from as before pyobject_getattrstring fetches an object' attribute value by name pyeval_callobject calls python function (or class or methodpyarg_parse converts python objects to values python/ integration