"pass all args in list" syntax

View: New views
4 Messages — Rating Filter:   Alert me  

"pass all args in list" syntax

by Gennadiy Rozental-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?

Gennadiy

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@...
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: "pass all args in list" syntax

by Stefan Seefeld :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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...

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@...
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: "pass all args in list" syntax

by Gennadiy Rozental-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stefan Seefeld <seefeld <at> sympatico.ca> writes:
> 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.

Right.

So no luck with 1.33.1 guess ;)

Will it get into 1.41?

Gennadiy

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@...
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: "pass all args in list" syntax

by Stefan Seefeld :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/09/2009 04:19 PM, Gennadiy Rozental wrote:

> Stefan Seefeld<seefeld<at>  sympatico.ca>  writes:
>    
>> 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.
>>      
> Right.
>
> So no luck with 1.33.1 guess ;)
>
> Will it get into 1.41?
>    

With 'this time' I was referring to the 1.40 release. So yes, it will be
in 1.41, too. :-)

     Stefan

--

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

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@...
http://mail.python.org/mailman/listinfo/cplusplus-sig