tags:

views:

75

answers:

2

hello, I have a C# program which executes a python scrip

How can I retrieve the python returning value in my C# program ?

thanks!

+2  A: 

As far as I know, you should use ScriptScope object which you create from the ScriptEngine object using CreateScope method

ScriptEngine engine = ScriptRuntime.Create().GetEngine("py");
ScriptScope scope = engine.CreateScope();

Then you can share variables between the C# program and the python script by doing this

scope.SetVariable("x", x);
bashmohandes
I assume this is only for IronPython? Still interesting though.
pufferfish
bashmohandes
+1  A: 

if your using System.Diagnostics.Process to launch your python script, then you can get the return code after process exit

using

process.ExitCode
Pradeep