Embedding - Local dictionaries for local scripts
Martin v. Löwis
loewis at informatik.hu-berlin.de
Mon Sep 9 03:50:57 EDT 2002
chris.walsh at real-sense.com (Chris Walsh) writes:
> PyObject* PyRun_String(
> char *str,
> int start,
> PyObject *globals,
> PyObject *locals);
>
> I have seen some stuff in comp.lang.python about creating a dict and
> adding the __builtin__ module but I have been searching now for an
> hour and cannot find it.
>
> Can anyone point me to some code which creates this dictionary?
The globals/locals dictionary is not really different from any other
dictionary; you create them with PyDict_New. Python should
transparently add an __builtins__ into the globals dictionary if there
is none, but you can copy the __builtins__ entry just as well yourself
(via PyDict_SetItemString).
HTH,
Martin
More information about the Python-list
mailing list