--- I'm trying to
run a method in a python file called pyFile.py...
class dc:
def
proc1(var1):
print
"Proc1 was run:",var1
def
main():
pass
if __name__ ==
"__main__":
main()
--- and here's my c
program:
int main(){
printf("Hello
World!\n");
PyObject
*mainModule,*globals,*pyRunFile,*runMethod;
FILE
*pythonFileP;
Py_Initialize();
pyProxy *dc = new pyProxy();
char *filename =
"pyFile.py";
pythonFileP =
fopen(filename,"r+");
if (pythonFileP !=
NULL){
mainModule = PyImport_AddModule("__main__");
globals = PyModule_GetDict(mainModule);
pyRunFile =
PyRun_File(pythonFileP,filename,Py_file_input,globals,globals);
runMethod =
PyObject_CallMethod(pyRunFile,"proc1","s","Blah");
fclose(pythonFileP);
Py_Finalize();
}else{
printf("File not opened!\n");
}
return
0;
}
--- It's crashing
when I try to do the PyObject_CallMethod. How do I get at this
method? I'm not sure what the python file needs to look like either.
I just put it in the class, but that didn't help either.
Thanks for any
help!
Mark
-- http://mail.python.org/mailman/listinfo/python-list