Self-referencing class: concrete python class from C interface -
i trying design c interface extended in python (using ctypes ). i've used natural idiom in c: struct format { int (*can_open)(const char *filename); struct format * (*open)(const char *filename); void (*delete)(struct format *self); int (*read)(struct format *self, char *buf, size_t len); }; it works nicely if want extend interface c directly: struct derived /* concrete implementation */ { struct format base; }; but do, implement interface python using ctypes. here have far: canopenfunc = ctypes.cfunctype(ctypes.c_int, ctypes.c_char_p) #openfunc = ctypes.cfunctype(ctypes.c_void_p, ctypes.c_char_p) #openfunc = ctypes.cfunctype(ctypes.pointer( python_format ), ctypes.c_char_p) #deletefunc = ctypes.cfunctype(none, ctypes.c_void_p) #readfunc = ctypes.cfunctype(ctypes.c_int, ctypes.c_void_p) def py_canopen_func( string ): print "py_canopen_func", string return 1 canopen_func = canopenfunc(py_canopen_func) #open_fun...