473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Py_BuildValue for char **?

js
Hi,

I'm writing a wrapper module of C API.
To make a C struct data avaiable to Python, I need to map C struct
into a PyObject.
I'm thinking that I use a tuple or dict to represent the struct
but a problem is one of the members of the struct is char **, which is
not supported by
Py_BuildValue.
Is there any idiomatic way of mapping char ** to Python?

Any suggestions, pointers would be appreciated.
Jul 9 '08 #1
1 2465
Is there any idiomatic way of mapping char ** to Python?

My recommendation is to not use Py_BuildValue. Instead, use
PyList_New, and then, in a loop, PyString_FromString/PyList_SetItem.

Regards,
Martin
Jul 10 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Helmut Jarausch | last post by:
Hi, is there a format code to return an unsigned int to Python via Py_BuildValue? Just using code 'i' gives negative values for values greater than 2**31. I've tried the code 'I' (with python...
2
by: Christian Vogel | last post by:
Hi comp.lang.python readers, are there routines to create a Python integer from unsigned C-integers? I only could find Py_BuildValue and PyInt_FromLong which both only use signed c-integers....
2
by: Torsten Mohr | last post by:
Hi, when i write an extension module in C and return a Py_Object* that i've built with Py_BuildValue, do i need to use Py_INCREF on that before i return it to python from my extension module or...
2
by: ashtonn | last post by:
Hello, 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 -Thanks, Ashton
2
by: Martin Kulas | last post by:
Hallo! I have a problem with Py_BuildValue: I want to convert an unsigned int to a PyObject *. http://docs.python.org/api/arg-parsing.html says that I can use "I" as a format string. But it...
2
by: Sheldon | last post by:
Hi, I have a function that creates python objects out of C arrays and returns them to Python. Below is a working example that I later want to expand to return 12 arrays back to Python. The...
5
by: Christian Meesters | last post by:
Hi I'm having trouble with Py_BuildValue. I was able to pinpoint the following statement as the one causing a seg. fault with my script: static PyObject * funcname(PyObject *self, PyObject...
4
by: spectrumdt | last post by:
Hello. I am trying to extend Python with some C code. I made a trivial "Hello World" program in C that I am trying to wrap in "boilerplate" for inclusion in a Python program. But I can't compile...
3
by: Christian Meesters | last post by:
Hi, currently I have a problem understanding Py_BuildValue. I have this code: static PyObject *function(PyObject *self, PyObject *args) { PyObject * python_return_value = NULL; PyObject *...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.