3

I have one piece of code written in Python 3. Inside of it I have this function:

def a_star(matrix, start, goal):

It uses this 2 libraries to work:

import numpy
from heapq import *

And returns an array.


But the program must have a GUI and in Python implementing it is hard and ugly.

I just want to execute that function from other program (using Java or C#) how can I do that?

Thanks

Juan T
  • 1,219
  • 1
  • 10
  • 21
Iván E. Sánchez
  • 1,183
  • 15
  • 28
  • 1
    You'd have to embed Python in Java or C#. It would most likely be easier just to rewrite that function in Java or C# however. – vallentin Apr 28 '17 at 02:48
  • yep, but the the function is really a messy code I don't really understand how it works. So is not a simplest way? what if the hole python program returns only a string in console? is that easy? – Iván E. Sánchez Apr 28 '17 at 02:51
  • 1
    Try to read (example 1)[http://stackoverflow.com/questions/33004907/run-python-py-script-from-c-sharp] & (example 2)[http://stackoverflow.com/questions/33669450/execute-a-python-script-in-c-sharp] for C#, then (example 3)[http://stackoverflow.com/questions/16447410/how-to-execute-python-script-from-java] & (example 4)[http://stackoverflow.com/questions/9006520/running-python-scripts-in-java] for Java. – Tetsuya Yamamoto Apr 28 '17 at 03:29
  • Python's `Tkinter` is not that bad for UI, have you really taken a look? It's definitely not worse than Swing :) Anyway, I'd agree with @Vallentin. – Josep Valls Apr 28 '17 at 03:30

1 Answers1

0

As all of these programming languages use their own programming models it would not be possible to directly call any function written in one language from another language. In this case, however, if your Python application supports SOAP or HTTP based service calls then you can still achieve it.

Peeyush
  • 95
  • 8