[C++-sig] One more question about method with argc, argv like arguments
wl at flexis.de
Tue Oct 25 13:05:05 CEST 2005
> Certainly this question has already been posted on this list but I don’t
> really find example of how it could be solved.
> I want to wrap a class which has constructor taking arguments like the
> famous “int argc, char *argv”
> and build instance of this class in python using
Wrap it to use only a python list.
> It is a quite common problem. As the second parameter is a pointer to
> pointer I guess that
> there is a special trick to be used here.
> Can anyone send me brief example of how this could be wrapped ?
Use injected constructors for this:
/* client_arg */
std::auto_ptr<MyClass> class_arg(boost::python::list args)
/* conversion here from python list to argc, argv */
std::auto_ptr<MyClass>myC(new MyClass(&argc, argv));
/* cleanup */
Conversion is left as an example. :-)
Look at test code for injected constructors !
bye by Wolfgang
More information about the Cplusplus-sig