[C++-sig] Re: embedding examples

Ingo Luetkebohle ingo at fargonauten.de
Mon Mar 1 16:11:38 CET 2004

Hello David,

thanks for the hints.  There was a slight run-time problem with the
code, which I solved as explained below.  I hope my "fix" doesn't have
any side-effects.

Am Mo, den 01.03.2004 schrieb David Abrahams um 14:15: 
>     // Retrieve the main module's namespace
>     dict main_namespace(
>          extract<dict>(main_module.attr("__dict__"))
>     );

If I use that verbatim, an exception is thrown and PyErr_Print() prints

	TypeError: No to_python (by-value) converter found for C++ type:

I'm assuming that is because 'attr' returns an object_attribute, not a
PyObject* and for extract to work, some behind-the-scenes conversion
creates the above error.  Correct?


	dict main_namespace(main_module.attr("__dict__"));

works fine and seems simpler, too.



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

More information about the Cplusplus-sig mailing list