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!

1

1 Answer 1

-1

It's documented in the official wiki ...

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

Sign up to request clarification or add additional context in comments.

1 Comment

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 -.-

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.