3

I want to call a python function from a C function. I need to import the python module in the c file and call the function I need, but nothing found on internet about this helps me because I actually do a ping pong between Python project and C project. I only run the python project. I load the library(dll) of the C project in python module, and after that I call in python a function from C project (this part works just fine) and after that in C project happends some events and in a callback function I want to call a function from python. Any idea how to do this?

The example found on internet like this one http://www.daniweb.com/software-development/python/threads/31682/calling-python-function-from-cc does't work in this case, because the python interpreter is already initialized and when I try to import the module it crashes...

Thanks!

Ariana Bitu
  • 39
  • 1
  • 2
  • 1
    possible duplicate of [Calling a python method from C/C++, and extracting its return value](http://stackoverflow.com/questions/3286448/calling-a-python-method-from-c-c-and-extracting-its-return-value) – MARK Aug 27 '13 at 14:17

1 Answers1

-1

It's documented in the official wiki ...

http://docs.python.org/2/extending/extending.html#calling-python-functions-from-c

user1154
  • 109
  • 4
  • 1
    That's terrible documentation, though, and it only describes the case where you get the python function passed from python through a function provided in C. What's completely missing is a description of how to lookup a python function from C -.- – yeoman Oct 15 '16 at 15:47