[C++-sig] "pass all args in list" syntax

Stefan Seefeld seefeld at sympatico.ca
Fri Oct 9 13:58:40 CEST 2009


On 10/09/2009 02:25 AM, Gennadiy Rozental wrote:
> Hi,
>
> In native Python  I can do something like this:
>
>      def goo(a,b,c):
>          return a+b+c
>
>      ll = [1,2,3]
>      goo( *ll )
>
> And it will pass all the arguments properly. I need similar functionality in C++:
>
> Given
>
> bp::object func;
> bp::list args;
>
> I'd like to invoke the function like this func( *args );
>
> Is there syntax in Boost.Python to achieve this? Or I need to resort to ugly
> switch statement?
>    

I added support for the above quite a while ago (and I'm assured that 
this time it even made it into the release branch in time ;-) ).
Thus, you can construct a list and keyword, then pass to a python 
callable as '*args' and '**kwds' respectively.

Regards,
         Stefan

-- 

       ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list