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

Faheem Mitha faheem at email.unc.edu
Fri Jul 2 18:18:59 CEST 2004

On Fri, 2 Jul 2004 10:43:29 -0500, Chad Austin <caustin at gmail.com> wrote:
> Faheem:  I think you're confused about one point.  All extension
> modules "embed the interpreter".  Since Python has loaded them, they
> all have access to the Python/C API and can do what they wish with it.

If you say so. I'm too ignorant about how these things work to have an

>  Your real problem is that you don't seem to have the 'file' builtin. 
> You should put more work into trying to decompose and solve that
> problem.

I've been trying...  Actually, I don't think I have ever put so much
effort before into getting a library working.

> Now that I think about it, perhaps your extension module doesn't have
> direct access to the builtins, while __main__ does.  Try changing your
> hard-coded script to:
>           "from __builtin__ import *\n"
>           "hello = file('hello.txt', 'w')\n"
>           "hello.write('Hello world!')\n"
>           "hello.close()"

I've tried this already.  I think someone else suggested this. I get
(after building with bjam):

In [1]: import embed_ext

In [2]: embed_ext.foo()
ImportError                               Traceback (most recent call last)



ImportError: __import__ not found


I don't know what this means. :-( . Perhaps simply that it does not
have the `import' builtin available to import `__builtin__'. :-) Have
you been able to reproduce any of these results? Thanks.


More information about the Cplusplus-sig mailing list