How pass array from C to python function

Praveen Patil praveen.patil at
Thu Sep 19 15:43:11 CEST 2002

Hi ,

I have problem in passing array to python function.
Please help me passing array to python function.

Here is my  'C' program

void  RECEIVE_IL_STATE_S( int Instance , int vital_data[5])
    PyObject* ret;
    PyObject* mylist;
    int count;
    mylist = PyList_New(5);
    for (count=0; count< 5; count++) {
          myint = PyInt_FromLong(vital_data[count]);
    arglist = Py_BuildValue("O", mylist);
    ret = PyEval_CallObject(my_callback , arglist);

Here is my Python program

G_Logfile          = None

def TestFunction(a):
    G_Logfile = open('Pytestfile.txt', 'w')
    G_Logfile.write("%d \n"% a[0])
    G_Logfile.write("%d \n"% a[1])



[ The information contained in this e-mail is confidential and is intended for the named recipient only. If you are not the named recipient, please notify us by telephone on +44 (0)1249 442 430 immediately, destroy the message and delete it from your computer. Silver Software has taken every reasonable precaution to ensure that any attachment to this e-mail has been checked for viruses. However, we cannot accept liability for any damage sustained as a result of any such software viruses and advise you to carry out your own virus check before opening any attachment. Furthermore, we do not accept responsibility for any change made to this message after it was sent by the sender.]

More information about the Python-list mailing list