PyRun_String using my module in a def

Alex Martelli aleax at mac.com
Thu Jul 5 05:23:33 CEST 2007


Stuart <stuart.tett at gmail.com> wrote:
   ...
> PyObject *rstring = PyRun_String( cmd, Py_file_input, main_dict,
> dlfl_dict );

You're passing difl_dict as the "locals" to PyRun_String -- but a
function has its own locals, so it won't use those locals.  Just update
main_dict with difl_dict (that's the equivalent of the "from difl import
*" which you appear to desire) and use main_dict for both globals and
locals in your PyRun_String call.


Alex



More information about the Python-list mailing list