[C++-sig] Re: compile errors with embedding example from tutorial

David Abrahams dave at boost-consulting.com
Thu Jul 1 18:50:45 CEST 2004

Graeme Lufkin <graeme.lufkin at gmail.com> writes:

>     I've had similar problems, and have slogged my way to figuring
> them out.  The tutorial is wrong, at least on gcc 3.2.3.

I think the tutorial is right in CVS.  Have you checked that?


>   Here's what you want:  After calling Py_Initialize(), you should get
> the Python main namespace object by doing:
> handle<> main_module(borrowed( PyImport_AddModule("__main__") ));
> dict main_namespace = extract<dict>(PyModule_GetDict(main_module.get()));

Seems harder than neccessary.

object main_module = object(handle<> (borrowed(
                        PyImport_AddModule("__main__") )));

object main_namespace = main_module.attr("__dict__");

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list