[C++-sig] Re: compile errors with embedding example from tutorial
David Abrahams
dave at boost-consulting.com
Tue Jun 29 17:51:48 CEST 2004
Faheem Mitha <faheem at email.unc.edu> writes:
> On Mon, 28 Jun 2004 15:56:13 -0500, Chad Austin <caustin at gmail.com> wrote:
>> On Mon, 28 Jun 2004 17:48:59 +0000 (UTC), Faheem Mitha
>> <faheem at email.unc.edu> wrote:
>>>
>>> On Sun, 27 Jun 2004 23:46:06 -0500, Chad Austin <caustin at gmail.com> wrote:
>
>> Nope, sorry... I had a problem similar to that in that __builtins__
>> wasn't getting set in my modules, but I was doing some weird stuff.
>> You may want to at least check that __builtins__ is set in your
>> script.
>
> How should I do that? I thought that
>
> handle<> main_module(borrowed( PyImport_AddModule("__main__") ));
> handle<> main_namespace(borrowed( PyModule_GetDict(main_module.get())));
>
> should do the trick, though I don't really understand what these lines
> do.
What specifically are you confused about? Did you check the docs?
I don't know why you'd do it that way when you can write:
object main_module(handle<>(borrowed( PyImport_AddModule("__main__"))));
object main_namespace = main_module.attr("__dict__");
instead.
> I wonder if the fact that I am calling the interpreter inside an
> extension module is causing any problems.
Certainly not. Calling the interpreter inside an extension module is normal.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list