469,293 Members | 1,335 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,293 developers. It's quick & easy.

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 2986
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 this site, you agree to our Privacy Policy and Terms of Use.