[C++-sig] Calling python from c++ with tuple and dict args.

David Abrahams dave at boost-consulting.com
Tue Mar 7 21:00:42 CET 2006


David Abrahams <dave at boost-consulting.com> writes:

> Alex Mohr <amohr at pixar.com> writes:
>
>> Thanks Markus,
>>
>> I was planning to use PyObject_Call which takes a tuple and a dict if I 
>> couldn't find a nice boost python way to do it.
>>
>> It seems like it would be possible to do something like this:
>>
>> bp::object::operator()(bp::unpacked_tuple const &args,
>>                         bp::unpacked_dict const &kw) {
>>      // call as self(*args, **kw)
>> }
>>
>> And then define unary * operators for tuple and dict so that *tuple 
>> would produce an unpacked_tuple and **dict would produce an unpacked_dict.
>>
>> Alex
>
> That's ******* E V I L *****  !!!
>
> and I love it!  Post a patch including tests and I'll check it in.

Huh, it looks like we should really extend all the overloads on object
so you can do:

   o(1, 2, 3, *t, **d)

That might be a touch more complex.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list