C FFI: easy conversion from list to argv?

B

Burton Samograd

Hi,

I'm trying to update the fuse python bindings to my app and I was
curious if there were any C utility functions that would turn a
sys.argv into a C style argv array, or am I going to have to write
those myself?

Thanks.
 
B

Burton Samograd

Burton Samograd said:
I'm trying to update the fuse python bindings to my app and I was
curious if there were any C utility functions that would turn a
sys.argv into a C style argv array, or am I going to have to write
those myself?

Following up to myself again...found the solution:

----------------------------------------------------------------------
PyObject *argv; /* value from PyArg_ParseTupleAndKeywords elsewhere */
int _argc = PySequence_Length(argv);
char **_argv = malloc(_argc*sizeof(char**));
int i;
for(i=0;i<_argc;i++)
_argv = PyString_AsString(PyList_GetItem(argv, i));
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top