Pyrex

Bjorn Pettersen BPettersen at NAREX.com
Thu Dec 26 15:37:08 EST 2002


> From: frederic cabaud [mailto:fcabaud at free.fr] 

[snip french original ;-)]

>    My need is to be able to to call python from C several 
> times, and, on the another hand, to allow python shell to 
> keep its (python) data. So, I dont have to call several time 
> the python shell, but to send several requests to the SAME shell.
> 
>    The aim is to use autonoms python classes (I already have 
> them) which can ALSO be called from C.

As with a few others here, my French is enough to understand just not good enough to reply ;-)

You should definitely check out Boost.Python. It makes embedding relatively trivial obviating the need to create shared libraries for your Python wrappers (which really tend to get in the way when you're embedding only). IMHO, every other alternative is either cumbersome or unclear when it comes to object ownership issues <.5 wink>.

The latest documentation is available at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/doc/index.html (the tutorial should get you up to speed quickly).

A complete embedding example (calling a Python class derived from a c++ class) is at: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/test/embedding.cpp (look ma' no reference counting! ;-)

To call Python objects, check: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/doc/v2/callbacks.html

To subscribe to the (extremely helpful) discussion list, start at: http://www.python.org/sigs/c++-sig/

-- bjorn




More information about the Python-list mailing list