Embedding Python question.

Thomas Troeger thomas.troeger.ext at siemens.com
Tue May 20 05:35:23 EDT 2008


Dear all,

I've successfully embedded the Python interpreter into a set of C/C++ 
application programs that use a larger library project with information 
from http://docs.python.org/api/api.html and 
http://docs.python.org/ext/ext.html. Now I want to wrap classes and 
functions from the associated libraries so that I can write new 
applications completely in Python, but I'm not entirely sure how to 
start because I have some problems understanding which is the best way. 
It would be nice if someone could answer the following questions and 
clarify this matter:

- until now I've used the approach as documented in 
http://docs.python.org/ext/extending-with-embedding.html to extend the 
embedded interpreter and that works pretty well. I'd like to use a 
similar approach for other C applications. Can I write a C library that 
implements this technique and link it into all C applications that need 
Python support, or is there a better, more elegant way?

- in the documentation, there's an example that illustrates the creation 
of a python module for pure extending of a python script (the Noddy 
stuff). Do I have to make a separate module for each library I want to 
wrap? If yes, how can I manage the case where two libraries can access 
each other?

- if I write an extension module, how can I handle the case where the C 
wrapper methods want to call back into the same Python interpreter instance?

- I think my questions break down into a reference to documentation 
where a similar problem is explained in detail. Does anyone have such 
information?

Thanks!
Thomas.



More information about the Python-list mailing list