Creating Python Class Instances From C API
M.-A. Lemburg
mal at lemburg.com
Thu Oct 14 06:06:43 EDT 1999
bill barrington 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>)
>
> ...and then return the newly created instance.
>
> Anyone know how to do this?
The trick is to get a reference to the class object and then
*call* it with your init parameters. It will then return an
instance just like in Python.
For code, see the examples Fredrik pointed you at.
Hope that helps,
--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 78 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/
More information about the Python-list
mailing list