A question?

Ignacio Vazquez-Abrams ignacio at openservices.net
Sat Sep 8 19:28:30 EDT 2001


On Sat, 8 Sep 2001, vin wrote:

> PyImport_GetModuleDict()  which is the same as sys.modules and which
> returns a dictionary already contains 'exmpl'
> To see that just insert
>
>   PyRun_SimpleString("import sys\n");
>   PyRun_SimpleString("print sys.modules\n");
>
> after
>
>   module=PyImport_ImportModule("exmpl");
>
> Therefore inserting 'exmpl' module doesn't help.

Huh. Okay...

Ah, I think I have it.

Use PyEval_GetGlobals() to get a borrowed reference to the global dictionary
and use PyDict_SetItemString() to set it, or you can just use
PyModule_GetDict() to get the module's dictionary, then use PyDict_Keys().

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>





More information about the Python-list mailing list