print values from Py_BuildValue

"Martin v. Löwis" martin at v.loewis.de
Thu Jul 7 17:07:47 EDT 2005


ashtonn at gmail.com wrote:
> How do i print values returned by Py_BuildValue in Linux?
> 
> PyObject *obj = Py_BuildValue("{s:i}", "Status", status);
> 
> I need to print the Status value here

I'm confused. You say you need to print the Status value here,
but then you also say you want to print the value returned
from Py_BuildValue, which is *not* the status value, but
a dictionary.

You also don't say whether you want to print this using
Python code or C code, so this gives a total of four interpretations
of your question:

1. Print status from C, on Linux:

   printf("The status is %d\n", status);

2. Print status from Python:

   print dict_returned_from_buildvalue['Status']

3. Print value returned from Py_BuildValue, from Python:

   print dict_returned_from_buildvalue

4. Print value returned from Py_BuildValue, in C

   PyObject_Print(obj, stdout, 0);

HTH,
Martin



More information about the Python-list mailing list