Dpulicating "class Foo:" in C

Mark Charsley mark.charsley at REMOVE_THIS.radioscape.com
Fri Jul 19 12:54:00 EDT 2002


In article <memo.20020719121547.1864A at a.a>, 
mark.charsley at REMOVE_THIS.radioscape.com (Mark Charsley) wrote:

OK got a little further. The following seems to work fine

  PyObject* newModule = PyImport_ImportModule("new");

  PyObject* new_classobj = PyObject_GetAttrString(newModule,"classobj");
  PyObject* args = Py_BuildValue("s(){}","Configure");

  PyObject* ConfigClass = PyEval_CallObject(new_classobj,args);
  
However the following crashes nastily whenever I try to do anything with 
ConfigClass...

  PyObject* types = PyImport_ImportModule("types");

  PyObject* classType = PyObject_GetAttrString(types,"ClassType");
        
  PyObject* ConfigClass = _PyObject_New((PyTypeObject*)classType);
  
Is there any way to create a new Class Object from C without having to 
call into new.classobj?
  
-- 

Mark - personal opinion only, could well be wrong, not representing 
company, don't sue us etc. etc.



More information about the Python-list mailing list