[C++-sig] How to convert a Python Tuple into a C/C++ array?

aashish at iastate.edu aashish at iastate.edu
Thu May 20 22:01:08 CEST 2004


 I didn't use Python C API but I know that in boost.python its really
straight forward.

Well C++-sig is  boost.python forum (I guess, I am new to here :) )  ..
you can try python forum for your question and probably they can give you
a better answer.

Hope this helps.
~aashish

> Aashish,
>
> I am not using boost.python. Is there a plain way to convert a tuple into
> an
> array?
>
> Thanks,
>
> Jinming
>
>>From: aashish at iastate.edu
>>Reply-To: Development of Python/C++ integration <c++-sig at python.org>
>>To: "Development of Python/C++ integration" <c++-sig at python.org>
>>Subject: Re: [C++-sig] How to convert a Python Tuple into a C/C++ array?
>>Date: Thu, 20 May 2004 14:47:06 -0500 (CDT)
>>
>>Hi,
>>
>>Well I am not sure if you are using boost.python but if you are then you
>>can use vector_indexing_suite.
>>
>>There are some other ways too but they are more complicated than this
>> one.
>>
>>~regards,
>>aashish
>>
>>
>> > Hello everyone,
>> >
>> > While embedding my C++ program with Python, I am impeded by the
>>conversion
>> > from a Python Tuple to a C++ array.  I hope to get some assistance
>> from
>> > you
>> > guys.
>> >
>> > I have a sequence of float numbers to be passed from Python to C++,
>> with
>> > indefinite size. So I chose to use Tuple on the Python side.  Since
>> > PyArg_ParseTuple() has no appropriate format to parse Tuple (The Tuple
>> I
>> > am
>> > saying is not the Tuple of arguments) of arbitray size, I simply
>> passed
>> > the
>> > tuple as follows
>> >
>> > PyObject* myTuple;
>> >   if(!PyArg_ParseTuple(args,"O",&myTuple))
>> >     return NULL;
>> >
>> > Now I have the pointer, myTuple, to the Tuple passed in. How can I
>>convert
>> > the the entired tuple, myTuple pointing to, into a float array, or
>>convert
>> > an individual element into a C/C++ float number? Are there any
>>conversion
>> > functions?
>> >
>> > Any suggestions or hints will be deeply appreciated!
>> >
>> > Thanks in advance!
>> >
>> > Jinming
>> >
>> > _________________________________________________________________
>> > Best Restaurant Giveaway Ever! Vote for your favorites for a chance to
>>win
>> > $1 million! http://local.msn.com/special/giveaway.asp
>> >
>> >
>> > _______________________________________________
>> > C++-sig mailing list
>> > C++-sig at python.org
>> > http://mail.python.org/mailman/listinfo/c++-sig
>> >
>>
>>
>>-----------------------------------------------
>>Aashish Chaudhary       | Email:
>>Research Assistant      | ashish_cy at yahoo.com
>>Iowa State University   | aashish at iastate.edu
>>Ames, Iowa - USA        | Ph: (515) 441-1178
>>-----------------------------------------------
>>
>>_______________________________________________
>>C++-sig mailing list
>>C++-sig at python.org
>>http://mail.python.org/mailman/listinfo/c++-sig
>
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar – get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>


-----------------------------------------------
Aashish Chaudhary       | Email:
Research Assistant      | ashish_cy at yahoo.com
Iowa State University   | aashish at iastate.edu
Ames, Iowa - USA        | Ph: (515) 441-1178
-----------------------------------------------




More information about the Cplusplus-sig mailing list