[C++-sig] Re: Boost.Python scope

Stefan Seefeld seefeld at sympatico.ca
Fri Nov 7 18:16:51 CET 2003


Nicolas Fleury wrote:
> Stefan Seefeld wrote:
> 
>> Hi Nicolas,
>>
>> Nicolas Fleury wrote:
>>
>>> complete C++ API?  Or at least add a function to execute python code 
>>> and store the result in a boost::python::object?
>>
>>
>>
>> what you ask for is already there. I'm using it at work every day ;-)
>>
>> A+
>>
>>         Stefan
> 
> 
> Hi Stefan,
>     I guess I miss something in the doc... So how do I execute something 
> like "import pickle; pickle.load(open('myfile'))" and store the result 
> in a boost::python::object?  (or any better way)

python provides a couple of interfaces to deal with objects in general,
and specific types (dicts, strings, tuples, etc.) in particular. These
are mapped to C++ in boost.python, and the docs are here:

http://www.boost.org/libs/python/doc/tutorial/doc/basic_interface.html
http://www.boost.org/libs/python/doc/tutorial/doc/derived_object_types.html

the only missing thing is the execution of a little python snippet
(file or string), which is described at

http://www.boost.org/libs/python/doc/tutorial/doc/using_the_interpreter.html

hope this helps,
		Stefan





More information about the Cplusplus-sig mailing list