tags:

views:

95

answers:

2

If it doesn't use ironpython, how C# use cpython program(py file)?

Because there are some bugs that ironpython load cpython code.

A: 

It's not clear why you need to use C# at all, but have you considered just invoking python by running it as a separate process via System.Diagnostics.Process.Start()?

codekaizen
requires python to be installed
aloneguid
@aloneguid - Um, yea, that is the requisite of running python program... actually having python installed. Are you missing something here?
codekaizen
@aloneguid - but you can always compile your python program using py2exe or similar.
paffnucy
Well, no. Having python interpreter is not a requirement to run a python script. Depends on what author wants to achieve.
aloneguid
@aloneguid - Yes, it does depend on what the author wants to achieve. So, invoking python as a process is a possible valid way to go about it.
codekaizen
A: 

If you need strict CPython behavior and do not want to change Python program I am afraid that in this case you should spawn separate CPython process and interact with it via some RPC protocol (there are plenty to choose from) via pipe or network connection to localhost.

As alternative to "serialized" RPC you might use system's facilities e.g. COM if you're on Windows or D-Bus on Linux - but this would make code platform dependent and not necessarily simpler.

Petr Gladkikh