On Fri, 2 Jul 2004 10:43:29 -0500, Chad Austin <caustin@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 opinion.
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) /usr/local/src/boost/boost-1.31.0/libs/python/example/ bin/example/embed_ext.so/gcc/debug/shared-linkable-true/<console> /usr/local/src/boost/boost-1.31.0/libs/python/example/ bin/example/embed_ext.so/gcc/debug/shared-linkable-true/<string> 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. Faheem.