program the actual python code run from can come from wide variety of sourcescode strings might be loaded from filesobtained from an interactive user at console or guifetched from persistent databases and shelvesparsed out of html or xml filesread over socketsbuilt or hardcoded in programpassed to extension functions from python registration codeand so on callable objects might be fetched from python modulesreturned from other python api callspassed to extension functions from python registration codeand so on code files simply exist as filesmodulesand executable scripts in the filesystem registration is technique commonly used in callback scenarios that we will explore in more detail later in this but especially for strings of codethere are as many possible sources as there are for character strings in general for examplec programs can construct arbitrary python code dynamically by building and running strings finallyonce you have some python code to runyou need way to communicate with itthe python code may need to use inputs passed in from the layer and may want to generate outputs to communicate results back to in factembedding generally becomes interesting only when the embedded code has access to the enclosing layer usuallythe form of the embedded code suggests its communication mediacode strings that are python expressions return an expression result as their output in additionboth inputs and outputs can take the form of global variables in the namespace in which code string is runc may set variables to serve as inputrun python codeand fetch variables as the code' result inputs and outputs can also be passed with exported extension function calls--python code may use module or type interfaces that we met earlier in this to get or set variables in the enclosing layer communications schemes are often combinedfor instancec may preassign global names to objects that export both state and interface functions for use in the embedded python code callable objects may accept inputs as function arguments and produce results as function return values passed-in mutable arguments ( listsdictionariesclass instancescan be used as both input and output for the embedded code--changes made in python are retained in objects held by objects can also make use of the global variable and extension functions interface techniques described for strings to communicate with for concrete exampleconsider the discussion of server-side templating languages in the internet part of this book such systems usually fetch python code embedded in an html web page fileassign global variables in namespace to objects that give access to the web browser' environmentand run the python code in the namespace where the objects were assigned worked on project where we did something similarbut python code was embedded in xml documentsand objects that were preassigned to globals in the code' namespace represented widgets in gui at the bottomit was simply python code embedded in and run by code embedding python in coverview