Extending an embeded Python
Fredrik Lundh
fredrik at pythonware.com
Tue Apr 12 11:12:22 EDT 2005
Mikin von Flap wrote:
> PyObject* res0 = Py_InitModule( "stoneage", StoneAgeMethods );
> res1 = PyRun_SimpleString( "stoneage.log( \"test\" )\n" ); // FAIL
> res2 = PyRun_SimpleString( "log( \"test\" )\n" ); // FAIL
> res3 = PyRun_SimpleString( "print \"test\"\n" ); // OK
> Py_Finalize();
> This compiles without problems, but when I run it I can't use the "log"
> function. Result res0 is a non-null object.
> As far as I can understand the "Extending and Embedding the Python
> Interpreter" doc, res1 should work but it doesn't!
compare and contrast:
C:\Python24>python
Python 2.4 (#60, Nov 30 2004, 11:49:19)
>>> stoneage.log("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'stoneage' is not defined
>>> sys.platform
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'sys' is not defined
>>> import sys
>>> sys.platform
'win32'
</F>
More information about the Python-list
mailing list