Creating Python Class Instances From C API
bill barrington
bill.barrington at turner.com
Tue Oct 12 17:52:18 EDT 1999
Fredrick,
Thanks for pointing me in the right direction. The only bit of trouble
I had was figuring out that I needed to set 'args' to NULL and use the
keyword dictionary parameter instead in the call to PyInstance_New, i.e.
PyObject *data = Py_BuildValue("{s:s}", "<name>", "<value>");
PyObject *object = PyInstance_New(class_name, NULL, data);
It works great! Thanks again.
Regards,
Bill
Fredrik Lundh wrote:
> bill barrington <bill.barrington at turner.com> wrote:
> > I would like to create a python class instance using the python/C
> > API for eventual return back into "python space". IOW, I want to
> > accomplish the equivalent of the following python code, but from within
> > an extension:
> >
> > instance = Class(<whatever>)
>
> start here:
> http://www.python.org/doc/current/api/object.html
>
> and then look at the cPickle.c source code
> (see find_class, Instance_New, load_inst, ...).
>
> </F>
>
> coming soon:
> http://www.pythonware.com/people/fredrik/librarybook.htm
--
Bill Barrington
CNN Interactive - http://cnn.com
bill.barrington at cnn.com
404 827-5572
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/19991012/3738dd15/attachment.html>
More information about the Python-list
mailing list