471,893 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,893 software developers and data experts.

PyImport_ImportModule("sys")

Bulldog
I am new to this board and I am using Python 2.2.1 on Windows XP SP2. I am working on embedding some python functionality in a C++ win32 DLL, and I am having issues using the PyImport_ functions available in the python C API. More specifically I am trying to use Pyimport_ImportModule() to import sys, and it doesn't work. I have also tried using PyString_FromString() to convert the the string "sys" to a Python object to then use PyImport_Import(). Can't get it to work. The only way to properly import sys is to use PyRun_SimpleString("import sys"). I think this a pretty standard question but I haven't found a definite answer yet. does the problem come from the fact that sys is a built-in module? What are the limitations on the PyImport_ functions with respect to the different types of module one could try to import? TIA.
Jan 18 '07 #1
2 3143
bartonc
6,596 Expert 4TB
I've never tried to do it that way. I import the low level dll into the high level (Python) module using the ctypes library. That way I get the benefits of both worlds: Low level C doing work that must be optimized or hidden and Python taking care of things like memory management and OS interface.
Jan 18 '07 #2
I am not quite sure I understand your reply!
Jan 18 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.