Hello programmers of SO,
I am making a C# interface for a socketing,
The interface is made with C# but the code ressponsable for the actual socketing part is written in Python because writing that in C# Would be insanity,
i used some ironPython to execute the python code:
var engine = Python.CreateEngine();
engine.ExecuteFile(""); //directory is inside the quotes
but i need to pass some values (IP and all that jazz)
anyone know how?
I looked at How do I pass arguments to a Python script with IronPython and it would be too hard to implement so dont ask if that thread answers my question please
CodePudding user response:
You could store the data as a string in some file in c sharp, and you could have a thread in python constantly looking for the information. It would know when the information has been stored in the file if a certain keyword is passed along with it. For example (if you were using a textfile with a location called location)
File.WriteAllText(location, IPAdress "[IP]");
and here is the code for searching for it
foreach(string datainfo in File.ReadAllText(location).Split(Convert.ToChar("\n"))
{
if(datainfo.Contains("[IP]")
datainfo.Replace("[IP]","");
string Ip = datainfo;
}
I don't know how to deal with files in python but the python equivalent of the csharp code above should work.