[Pythonmac-SIG] Callback function problems

Michael Hudson mwh@python.net
12 Aug 2002 16:27:46 +0100


Matthew Smith <mps@utas.edu.au> writes:

> Hello
> 
> If this is better suited to a general python list then sorry...

Yes, but ne'er mind.

> I'm having problems setting up and using a callback function in my program
> that embeds python. I am using the following code:

> void callPythonFunc(long x, long y)
> {
>     PyObject *arglist;
>     PyObject *result;
>     long smaller;
>     
>     arglist = Py_BuildValue("[l,l]", x, y);

Try "Py_BuildValue("ll", x, y);" instead.  You want a list, not a
tuple.

>     result = PyEval_CallObject(pythonCallback, arglist);

Or

     result = PyEval_CallFunction(pythonCallback, "ll", x, y);

Cheers,
M.

-- 
    FORD:  Just pust the fish in your ear, come on, it's only a
           little one.
  ARTHUR:  Uuuuuuuuggh!
                    -- The Hitch-Hikers Guide to the Galaxy, Episode 1