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:
BOOST_PYTHON_MODULE(main) { class_<Form, boost::noncopyable, boost::shared_ptr<Form>>("Form") ; } then in main: ... try { object main = import("__main__"); object global(main.attr("__dict__")); boost::python::dict local; exec( "import main\n" "class Form1(main.Form):\n" " def __init__(self, A, *args, **kwargs):\n" " super().__init__(*args, **kwargs)\n\n" , global, local); // Get class object c_form1 = local["Form1"]; // Create instance object form1_instance = object(handle<>(PyObject_CallObject(c_form1.ptr(), make_tuple(1, 2).ptr()))); } catch(error_already_set &) { PyErr_Print(); } But it prints: Traceback (most recent call last): File "<string>", line 4, in __init__ Boost.Python.ArgumentError: Python argument types in Form.__init__(Form1, int) did not match C++ signature: __init__(struct _object *) Which is logical I think because it finds only default constructor. I've tried also raw_constructor from http://wiki.python.org/moin/boost.python/HowTo#A.22Raw.22_constructor but without success. Anyone know if it is somehow possible? Thanks Trigve _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig