Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass variable value from C++ to Python?

I have a sensor value which can be read using the C++ only because it was implemented using it , I want to pass location value (two float variable) of one sensor to Python. I have been reading a lot and I found shared memory , piping and more any idea what is the best way to do it ?

like image 511
ramtha Z28 Avatar asked May 09 '26 15:05

ramtha Z28


1 Answers

It's not clear from your question whether this is a standalone C++ program or a library.

If it's a standalone program, use the subprocess module to invoke it and read its output.

If it's a library, use Cython to construct a Python extension module that wraps the library. (It is not necessary to use Cython; Python extensions can be written by hand. But it will make the task significantly easier.)

like image 95
zwol Avatar answered May 12 '26 04:05

zwol