ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved