[C++-sig] Can I import a module in C++ and use in python script ?
by Atul Kshirsagar other posts by this author
Oct 20 2003 8:15AM messages near this date
[C++-sig] Problem with reinit of Numeric in embedded Python
|
Re: [C++-sig] Can I import a module in C++ and use in python script ?
I have following code in my C++ application using
python extension module "FlPythonModulesud".
Py_Initialize();
PyObject *m, *d, *m2;
m = PyImport_AddModule ("__main__");
d = PyModule_GetDict (m);
m2 = PyImport_ImportModuleEx ("FlPythonModulesud", d,
d, NULL);
PyDict_SetItemString (d, "FlPythonModulesud", m2);
I use python in multithreaded environment. I have
embedded a few C++ classes within pthon using Swig. I
run python expressions using PyRun_String().
A sample python expression looks like this;
from FlPythonModulesud import *
# Get collection pointer
collection = FlDataCollectionPtr(Collection)
# get collection size (num records in collection)
numRecords = collection.size()
print numRecords
Here FlDataCollectionPtr is a embedded class pointer
and Collection is a variable passed to python.
What I am trying to do is get rid OFF statement
from FlPythonModulesud import *
in the script programatically.
But the above PyImport_ImportModuleEx() doesn't serve
my purpose.
Any help will be appreciated !!!
Atul
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
Atul Kshirsagar
Pierre Barbier de Reuille
|