Embed extended Python
David LeBlanc
whisper at oz.net
Fri Sep 13 16:05:41 EDT 2002
The boost libary is a great C++ embedding/extending library for Python.
www.boost.org
David LeBlanc
Seattle, WA USA
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Mathieu Tremblay
> Sent: Friday, September 13, 2002 7:57
> To: python-list at python.org
> Subject: Embed extended Python
>
>
> Hello,
> I am quite new to Python and I'd like to embed extended python.
> The problem is that the documentation I can find on the internet is
> always related to C standard types and not to C++ objects.
>
> To extend python I use the really good SWIG tool and everything is
> fine. The problem comes when I try to call a python script that takes
> as an argument one of the class that I have defined in C++ through
> swig.
>
> Exemple:
> C++ class extended to python with SWIG, through the module wheel:
> CWheel
> {
> CWheel(){}
> ~CWheel(){}
> printWheel()
> {
> printf("I am a wheel");
> }
> };
> Now, let's suppose that the module is successfully exported and can
> be used in python. An example of simple python script would be :
> import wheel
>
> def thefunction(awheel):
> awheel.printWheel()
>
> Calling this function directly from python (supposing we provide the
> correct argument) works perfectly. The problem comes when I want to
> call this script from C++. Maybe It is a stupid question but here it
> is: How do you pass an existing CWheel as an argument to the function
> from C++??? How do you wrap a CWheel to a PyObject?
> I guess the method would be to use the function
> PyObject_CallObject(pFunc, pArgs); the pArgs being a PyTuple where I
> can set a PyObject to a position X. The problem is that all the
> examples that I find convert int, char*, long, double etc. to PyObject
> with built in python functions but no different/user defined class.
> Anybody can help?
>
> Thanks a lot,
> Mathieu
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list