Createing PyObjects from modules
ian reinhart geiser
geiseri at yahoo.com
Thu Oct 25 20:23:09 CEST 2001
-----BEGIN PGP SIGNED MESSAGE-----
I have a little confusion about python objects. I am trying to share an
object between C++ and my embedded python script. To do this I have found
little to no help from the Python docs or on the web as how to mirror a
complex object between the two. I have found that siplib the library that
makes SIP work has the ability to map C++ objects to python and vis versa.
sipMapCppToSelf -- Convert a C/C++ pointer to a Python instance
PyObject * sipMapCppToSelf(const void * cppPtr, PyObject * pyClass);
If the C/C++ pointer is recognized and it is an instance of a sub-class of
the expected class then the previously wrapped instance is returned.
Otherwise a new Python instance is created with the expected class. The
instance comes with a reference.
A pointer to the Python object instance (or Py_None if a NULL pointer was
cppPtr - A pointer to the C++ object.
pyClass - The expected Python class.
- From what I can tell in the code this pyClass is the class created by my
module that is being called from the embedded script. My question is how do
a make a PyObject out of it?
In python i do this:
from foo import *
bar = foo()
I tried this in C++ but it seems not to work:
PyObject *object = PyModule_New("foo");
Am I mis understanding the documentation here?
- -ian reinhart geiser
May all your PUSHes be POPped.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----
More information about the Python-list