> From: Jim Bosch <[email protected]> > To: [email protected] > Cc: > Sent: Friday, June 22, 2012 12:28 AM > Subject: Re: [C++-sig] C++ clas with (*args, **kwargs) constructor > > On 06/21/2012 06:07 PM, Trigve Siver wrote: >>> From: Jim Bosch <[email protected]> >>> To: [email protected] >>> Cc: >>> Sent: Thursday, June 21, 2012 11:57 PM >>> Subject: Re: [C++-sig] C++ clas with (*args, **kwargs) constructor >>> >>> On 06/21/2012 05:31 PM, Trigve Siver wrote: >>>> >>>> >>>> Hi, >>>> I'm trying to find some solution to my problem but without > succes. I >>> need to be able to export C++ class constructor that takes arbitraty > arguments >>> (as in python __init__(self, *args, **kwargs). Is it possible to have > this kind >>> of constructor? I've tried something like this: >>>> >>> >>> I believe this is not possible in Boost.Python. The closest > approximations I >>> know of are: >>> >>> - Use a static method or free function instead of a constructor for > this mode of >>> construction in Python. You can wrap a non-constructor with *args, > **kwds using >>> boost::python::raw_function. >>> >>> - Inherit from the wrapped class at the Python layer; the derived class > could >>> then have a constructor with *args, **kwds. >>> >> >> Thanks for reply :) Hmm I was trying with python::raw_function, but without > success also. Ok I'm gonna try a bit more with raw_constructor once more. >> > > Heh, I didn't even know about raw_constructor, because it isn't in the > reference docs for some reason. If it exists, then your problem very > likely is solvable and my response was totally bogus.
This raw_constructor isn't integrated in boost:python. It is from http://wiki.python.org/moin/boost.python/HowTo#A.22Raw.22_constructor as mentioned in previous mail. Maybe there is a little chance to make patch and add it to boost::python? :) > Glad I didn't discourage you. :) > > Jim Trigve _______________________________________________ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
