tags:

views:

270

answers:

2

hello

I have an external C# program which executes a python script using the Process Class.

my script returns a numerical code and I want to view that number with my C# program.

the problem is, I'm getting the return code of python.exe, instead of my script return number - in that case, "return 3"

any suggestions ? thanks

A: 

I haven't really done much with inter-language communication, so the simplest idea I can think of is have the Python script write its return code to a text file and then have the C# program open the file, read the return code, then close and delete the file.

There's probably a much simpler way to do it, but that's the first thing that came to mind.

JAB
+5  A: 

The interpreter does not return the value at the top of Python's stack, unless you do this:

if __name__ == "__main__":
    sys.exit(main())

or if you make a call to sys.exit elsewhere.

Here's a lot more documentation on this issue.

Mark Rushakoff
+1 for being much better than mine.
JAB