0

I have script in Python containing several functions, and one Callback (when event occurs). I would like to release some "package" from my script , which could be importable and usable for other users. Lets say: Some one can use it for creating GUI app in JAVA, another it will incorporate to his own C++ Gui app, and someone just will call my functions from another Python script.

Can you point me to right direction please?

Thanks.

WITC
  • 127
  • 9

1 Answers1

1

So you want to be able to call Python functions from Python, Java and C++?

  1. The Python case is just a matter of importing your module.
  2. To call Python functions from Java, try Jython: https://www.jython.org/index.html
  3. To call Python functions from C++, use the Python header files and this approach https://docs.python.org/3/extending/embedding.html. Alternatively, you can use Boost.Python: http://www.boost.org/doc/libs/release/libs/python/doc/index.html

Calling one language from another can be quite a tricky thing. An approach that would work in all languages and avoid major headaches would be to expose a proper public interface (command-line, http, etc) and consume this interface in the other languages.

Other references:

D Hudson
  • 1,004
  • 5
  • 12