[C++-sig] converting python list of strings to char *[]

Abhi abhi at qualcomm.com
Thu Mar 23 19:46:45 CET 2006



--On Thursday, March 23, 2006 8:41 AM -0500 Nat Goodspeed 
<ngoodspeed at solidworks.com> wrote:

>> -----Original Message-----
>> From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]
> On
>> Behalf Of Abhi
>> Sent: Wednesday, March 22, 2006 7:59 PM
>> To: c++-sig at python.org
>> Subject: [C++-sig] converting python list of strings to char *[]
>>
>> I have functions such as
>> int run(int argc, char* argv[])
>> which needs to be exported to python using Boost.Python.
>>
>> How do I pass to the char *argv[] from python?
>
> [Nat] Depending on how many such functions you have, wouldn't it be
> simpler to publish thin wrappers? In this case the run() function you
> call from Python would be defined to accept a list of Python strings,
> and would then construct both arguments for the real run() function from
> that list.

[Abhi] That's what I did: wrapped individual functions. But now we have 
quite a few more and it will be easier to just do it for the type: convert 
a list of string to char *[]. Is that possible? I was looking at the 
boost.python reference manual online, but did not see any examples.

thanks
- Abhi


>
> If you have many such functions, is it possible that pyplusplus would
> generate such wrappers automatically? (I'm not familiar with pyplusplus
> beyond the traffic I've seen here over the past few months.)
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig







More information about the Cplusplus-sig mailing list