[C++-sig] Re: compile errors with embedding example from tutorial
faheem at email.unc.edu
Thu Jul 1 22:34:49 CEST 2004
On Thu, 01 Jul 2004 12:50:45 -0400, David Abrahams
<dave at boost-consulting.com> wrote:
> 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__");
instead, which does not compile with gcc 3.3, at least for me.
In any case, as I already said, even when this compiles correctly, it
still does not seem to execute the interpreter correctly, ie. I get
NameError: name 'file' is not defined
Can you suggest what might be the problem here?
More information about the Cplusplus-sig