How to embed?

vin fractal97 at hotmail.com
Sat Sep 8 14:58:54 EDT 2001


Your function dumps the core at the line dict=PyModule_GetDict(module); . 
Besides PyDict_GetItemString needs 2 arguments.  

Vin 


> How about this:
> 
> ---
> #include <stdio.h>
> #include <Python.h>
> 
> int main(void)
> {
>   PyObject *module, *dict, *foo, *result;
>   double x=5.5, y=6.6;
> 
>   Py_Initialize();
> 
>   module=PyImport_ImportModule("exmpl");
>   dict=PyModule_GetDict(module);
>   foo=PyDict_GetItemString("foo");
>   result=PyObject_CallFunction(foo, "dd", x, y);
>   printf("The answer is %.2f!\n", PyFloat_AsDouble(result));
> 
>   Py_Finalize();
> 
>   return 0;
> };
> ---
> 




More information about the Python-list mailing list