extending Python - passing nested lists

Mark Dickinson dickinsm at gmail.com
Mon Jan 28 13:20:33 EST 2008


On Jan 28, 10:10 am, Christian Meesters <meest... at uni-mainz.de> wrote:
> Hi,
>
> I would like to write a C-extension function for an application of mine. For
> this I need to pass a nested list (like: [[a, b, c], [d, e, f], ...], where
> all letters are floats) to the C-function. Now, with the code I have the
> compiler is complaining: "subscripted value is neither array nor pointer".
> Can somebody tell me what's wrong?

Well, it's pretty clear:  you misspelt "length" as "lenght".  :)

PySequence_Fast doesn't return an array:  it returns a PyObject---in
this case, a PyObject corresponding to a Python tuple.  As the
compiler says, a PyObject is neither an array nor a pointer, so when
you write

dummy_list[i]

the compiler doesn't know what you mean.  You probably want to use
PySequence_Fast_GET_ITEM.  See the documentation at

http://docs.python.org/api/sequence.html#l2h-333

Mark



More information about the Python-list mailing list