/make new dictionary for code string namespace *#include main(int cvalpyobject *pdict*pvalprintf("embed-dict\ ")py_initialize()/make new namespace *pdict pydict_new()pydict_setitemstring(pdict"__builtins__"pyeval_getbuiltins())pydict_setitemstring(pdict" "pylong_fromlong( ))pyrun_string(" "py_file_inputpdictpdict)pyrun_string(" + "py_file_inputpdictpdict)pval pydict_getitemstring(pdict" ")/dict[' ' */run statements */same and */fetch dict[' '*pyarg_parse(pval" "&cval)printf("% \ "cval)py_decref(pdict)py_finalize()/convert to */result= *when compiled and runthis program creates this sort of outputtailored for this use case/pp /integrate/embed/basics/embed-dict embed-dict the output is different this timeit reflects the value of the python variable assigned by the embedded python code strings and fetched by in generalc can fetch module attributes either by calling pyobject_getattrstring with the module or by using pydict_getitemstring to index the module' attribute dictionary (expression strings worktoobut they are less directherethere is no module at allso dictionary indexing is used to access the code' namespace in besides allowing you to partition code string namespaces independent of any python module files on the underlying systemthis scheme provides natural communication mechanism values that are stored in the new dictionary before code is run serve as inputsand names assigned by the embedded code can later be fetched out of the dictionary to serve as code outputs for instancethe variable in the second string run refers to name set to by cx is assigned by the python code and fetched later by code as the printed result basic embedding techniques