Embedding python problem, related to PyObject_Print.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chun-Chieh Huang

    Embedding python problem, related to PyObject_Print.

    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_Import Module("merge") ;
    pDict = PyModule_GetDic t(pModule);
    pFunc = PyObject_GetAtt rString(pModule , "TopoCreato r");
    PyObject *theArg = PyString_FromSt ring("FOSS");
    theTopoDesigner = PyObject_CallFu nctionObjArgs(p Func, theArg);
    addPiconet_Topo = PyObject_GetAtt rString(theTopo Designer,"addPi conet");

    // Create
    PyObject *tmpList = PyList_New(maxN umber);
    // setting values of tmpList
    PyObject_Print( tmpList, stdout, 0);
    pValue = PyObject_CallFu nctionObjArgs(a ddPiconet_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!
  • Chun-Chieh Huang

    #2
    Re: Embedding python problem, related to PyObject_Print.

    Chun-Chieh Huang <jjhuang@cm.nct u.edu.tw> writes:
    [color=blue]
    > 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:[/color]

    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!

    Comment

    Working...