0

We have a tool written in C# where we write vb.net scripts. Now, I need to integrate python in it so that we can run python scripts in same tool. All, the tool does is send string command and capture the string response.

My question: do I need to write interpreter for this?How can I talk to python engine. Is there any other way I can implement this? Links to get it going would be helpful. Just started with python today!

Thanks!

5
  • Just invoke the python interpreter with your desired .py file and pipe the output wherever you want. If you don't want to use a file, the interpreter also has a -c command line parameter which accepts python statements to execute. Commented Mar 7, 2014 at 23:02
  • Hi Asad, I am still trying to find info about invoking python interpreter. Will get back to you on this. How about performance if python interpreter is invoked from the existing tool? Links and info is appreciated if any? Thanks! Commented Mar 8, 2014 at 0:09
  • The python interpreter is just the executable that runs python scripts. If you've installed it on a box and it's configured correctly, it's probably already on the path, in which case you can just open up a command line and type "python" or "py" to start an interactive python session. The interpreter also accepts command line arguments, such as a path to a python script which it can execute, or raw python statements for it to execute directly. Commented Mar 8, 2014 at 0:26
  • I am not sure what to tell you about "performance". What are you comparing performance against/between? Different python interpreters? Commented Mar 8, 2014 at 0:28
  • Is it possible that I can send commands to from tool__>python interpreter-->product. And capture response from interpreter and write to excel sheet? How about performance compared to sending commands directly to box from the tool Commented Mar 8, 2014 at 0:55

1 Answer 1

0

Look into IronPython to fill your scripting needs. IronPython will provide you all of the features of Python but from within the .Net framework. Here is a previous question concerning embedding IronPython in C#

Michael Foord has an post on embeddeding IronPython into C#. There are several methods to achieve this goal. The simplest being to create a hosting engine from within C# and embed a string of Python code that will be executed.

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

Comments

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.