I am in need of the dynamics of ironpython in my c# application. I am able to process simple scripts as I have a c# function that compiles the ironpython and outputs the script. The problem with this is that it eliminates the dynamics that I require. For example if in the python code I send information to the user via an accessible c# class, and then pause for a response from the user before sending the final information. This is not possible in my current method as the entire script needs to be compiled before any output is received.

How do I run python scripts dynamically in C#

Here is the code I am using
Code:
private ScriptEngine pyEngine = null;
        private ScriptRuntime pyRuntime = null;
        private ScriptScope pyScope = null;
        private PythonInteractive pi = new PythonInteractive();

        public void testing()
        {
            if (pyEngine == null)
            {
                pyEngine = Python.CreateEngine();
                pyScope = pyEngine.CreateScope();
                pyScope.SetVariable("pi", pi);
                pi.AddText("Python initialized...");
            }
            CompileSourceAndExecute("login");
        }
        public void CompileSourceAndExecute(string filename)
        {
            string fileLoc = Path.GetFullPath(@"../../data/" + filename + ".py");
            ScriptSource source = pyEngine.CreateScriptSourceFromFile(fileLoc);
            CompiledCode compiled = source.Compile();
            //Executes in the scope of python
            compiled.Execute(pyScope);
        }