Re: parsing a tuple in embedded python
- From: "Fredrik Lundh" <fredrik@xxxxxxxxxxxxxx>
- Date: Sun, 30 Oct 2005 14:44:50 +0100
jenkins.justin@xxxxxxxxx wrote:
> I am returning a tuple from my python method and am stuck trying to
> figure out how to read it into a C array using PyArg_Parse.
> My C Code:
> int array[3];
> PyArg_Parse(return, "(iii)", &array);
>
> My Python Code:
> mytuple = (1,2,3)
> return mytuple
>
> That gives me a segmentation fault. What am I doing wrong?
you're not providing enough arguments; "iii" means three pointers, not
one. try:
PyArg_Parse(return, "(iii)", array, array+1, array+2)
instead. or, if you prefer maximum clarity:
PyArg_Parse(return, "(iii)", &array[0], &array[1], &array[2])
(I assume you left out the error handling code; ignoring the return value
from PyArg_Parse is not a good idea)
</F>
.
- Follow-Ups:
- Re: parsing a tuple in embedded python
- From: jenkins . justin
- Re: parsing a tuple in embedded python
- References:
- parsing a tuple in embedded python
- From: jenkins . justin
- parsing a tuple in embedded python
- Prev by Date: Re: lambda functions within list comprehensions
- Next by Date: Need Python Pro for Help!! Plzz
- Previous by thread: parsing a tuple in embedded python
- Next by thread: Re: parsing a tuple in embedded python
- Index(es):