[C++-sig] Re: embedding examples

Ingo Luetkebohle ingo at fargonauten.de
Tue Mar 2 17:03:00 CET 2004

Am Mo, den 01.03.2004 schrieb David Abrahams um 14:15:
>     // Retrieve the main module
>     object main_module = python::extract<python::object>(
>         PyImport_AddModule("__main__")
>     );

One word of caution: extract does not seem to check for NULL pointers. 
PyImport_AddModule never returns NULL, but other functions do.  E.g., I
was using PyImport_ImportModule and when it can't find the module, it
returns NULL.

To work around that, I use handle<> on the very first call like that,
then initialize an object and stick with Boost.Python calls afterwards.

Thanks again for the help :)


Soll doch jeder bleiben, wie er gerne wäre.

More information about the Cplusplus-sig mailing list