0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you i had a massive migraine looking on the around internet, have a nice year.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.