How to call IronPython function from C#/F#? -


To use this kind of follow-up questions

C / C ++ function from Python , SWIG for example is the easiest solution, if we have a python function, is also possible with the Python C API follows:

 def add (x, y): return (x + 10 * y) 

we can come up with the rapper to use the Python C.

 double Add (double a, double b) {PyObject * X, * Y, * pValue, * pArgs; Double res; Paraj = PETplay_New (2); X = Py_BuildValue ("D", A); Y = Py_BuildValue ("D", B); PyTuple_SetItem (PARGS, 0, X); PyTuple_SetItem (PR, 1, Y); PValue = PyEval_CallObject (pFunc, pArgs); Res = PyFloat_AsDouble (Pivotal); Py_DECREF (x); Py_DECREF (Y); Py_DECREF (pArgs); Return ridge; } 

How about IronPython / C # or F #?

  • How to call IronPython from C # / F # function? Or, is there a SWIG equivalent tool in IronPython / C #?
  • How to call the IronPython function with C # / F #? I think I can use "engine.CreateScriptSourceFromString" or similar, but I need to find the way to call the IronPython function like the C # / F # function, not to write the code in the string, but anybody Reading from the file.
  • You say "now write code in a string, but reading from a file, then OK, read the file.

    Python # F: From

      Let's File =. Read all lines ("foo.py") engine = python. Prepare () script.source = engine. CETSpcsourceframestring (s, sourcecodeindex.technits) ...  

    F # from Python:

      import clr clr.AddReferenceToFile ("SomeFsLib.dll")  

    I have received this from a link to this question. Did not try, but, like, it is straightforward, I think it 'just works' know what you are asking for it.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -