> From: Trigve Siver <trig...@yahoo.com> > To: Development of Python/C++ integration <cplusplus-sig@python.org> > Cc: > Sent: Thursday, June 21, 2012 11:31 PM > Subject: [C++-sig] C++ clas with (*args, **kwargs) constructor > > ... > 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(); > }
Bad formatting, sorry: 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(); } >... Trigve _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig