perhaps the simplest way to run python code from is by calling the pyrun_simple string api function with itc programs can execute python programs represented as character string arrays this call is also very limitedall code runs in the same namespace (the module __main__)the code strings must be python statements (not expressions)and there is no direct way to communicate inputs or outputs with the python code run stillit' simple place to start moreoverwhen augmented with an imported extension module that the embedded python code can use to communicate with the enclosing layerthis technique can satisfy many embedding goals to demonstrate the basicsthe program in example - runs python code to accomplish the same results as the python interactive session listed in the prior section example - pp \integrate\embed\basics\embed-simple /******************************************************simple code stringsc acts like the interactive promptcode runs in __main__no output sent to *******************************************************#include /standard api def *main(printf("embed-simple\ ")py_initialize()pyrun_simplestring("import usermod")pyrun_simplestring("print(usermod message)")pyrun_simplestring(" usermod message")pyrun_simplestring("print(usermod transform( ))")py_finalize()/load py file */on python path */compile and run *the first thing you should notice here is that when python is embeddedc programs always call py_initialize to initialize linked-in python libraries before using any other api functions and normally call py_finalize to shut the interpreter down the rest of this code is straightforward-- submits hardcoded strings to python that are roughly what we typed interactively in factwe could concatenate all the python code strings here with \ characters betweenand submit it once as single string internallypyrun_simplestring invokes the python compiler and interpreter to run the strings sent from cas usualthe python compiler is always available in systems that contain python compiling and running to build standalone executable from this source fileyou need to link its compiled form with the python library file in this "libraryusually means the binary basic embedding techniques