Embedding python problem, related to PyObject_Print.

  • Thread starter Chun-Chieh Huang
  • Start date
C

Chun-Chieh Huang

Dear all,

I carefully lookup PyObject_Print in the API manual, but I can't find
the resolution. And the problem is described below:

I embed python into C++ code as follows:

// First register function objects
pModule = PyImport_ImportModule("merge");
pDict = PyModule_GetDict(pModule);
pFunc = PyObject_GetAttrString(pModule, "TopoCreator");
PyObject *theArg = PyString_FromString("FOSS");
theTopoDesigner = PyObject_CallFunctionObjArgs(pFunc, theArg);
addPiconet_Topo = PyObject_GetAttrString(theTopoDesigner,"addPiconet");

// Create
PyObject *tmpList = PyList_New(maxNumber);
// setting values of tmpList
PyObject_Print(tmpList, stdout, 0);
pValue = PyObject_CallFunctionObjArgs(addPiconet_Topo, tmpList);

The problem is that if I comment out the line "PyObject_Print," I'll
get an error message:
"TypeError: addPiconet() takes exactly 2 arguments (3 given)"
But if I add back the PyObject_Print line, it works as
expected. However, I don't need PyObject_Print when the system is
finished; I use it for debugging purpose. The "addPiconet" method
takes a list as an argument, which is declared as:
def addPiconet(self, aList):
Blah blah blah

I really don't know how to solve it. How can I make it work without
PyObject_Print? Any suggestion? Thanks in advance.

Albert
--
Chun-Chieh Huang, aka Albert E-mail: jjhuang AT cm.nctu.edu.tw
¶À«T³Ç
Department of Computer Science
National Tsing Hua University MIME/ASCII/PDF/PostScript are welcome!
HsinChu, Taiwan NO MS WORD DOC FILE, PLEASE!
 
C

Chun-Chieh Huang

Chun-Chieh Huang said:
Dear all,

I carefully lookup PyObject_Print in the API manual, but I can't find
the resolution. And the problem is described below:

I embed python into C++ code as follows:

Sorry I didn't specify the platform. Below is my python version and
platform, but I use g++-2.96 to compile the C++ code, which embeds
python. Is it a problem of different compiler versions?

Python 2.3.3 (#1, Jan 5 2004, 14:18:28)
[GCC 3.3.1 (Mandrake Linux 9.2 3.3.1-2mdk)] on linux2
--
Chun-Chieh Huang, aka Albert E-mail: jjhuang AT cm.nctu.edu.tw
¶À«T³Ç
Department of Computer Science
National Tsing Hua University MIME/ASCII/PDF/PostScript are welcome!
HsinChu, Taiwan NO MS WORD DOC FILE, PLEASE!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top