[Python-Dev] Best practice for new namespace (from C/API)
Oleg Broytman
phd at phd.pp.ru
Thu Jul 29 12:23:19 CEST 2010
Hello.
We are sorry but we cannot help you. This mailing list is to work on
developing Python (adding new features to Python itself and fixing bugs);
if you're having problems learning, understanding or using Python, please
find another forum. Probably python-list/comp.lang.python mailing list/news
group is the best place; there are Python developers who participate in it;
you may get a faster, and probably more complete, answer there. See
http://www.python.org/community/ for other lists/news groups/fora. Thank
you for understanding.
Though I must admit the question is deeper than usual.
On Thu, Jul 29, 2010 at 08:11:39AM +1000, Campbell Barton wrote:
> - Whats the best way to manage the namespace for running multiple
> scripts one after another? clear and initialize __main__'s dict each
> time?, keep a copy and restore it after each run?
> - should the original __main__ namespace be restored after running a script?
> - pickle expects: __import__("__main__").__dict__ == ***the current
> namespace***, is this apart of the python spec or just something
> specific to pickle?
> - PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins()) acts
> differently to PyDict_SetItemString(dict, "__builtins__",
> PyImport_AddModule("builtins")), using the PyEval_GetBuiltins() dict
> adds every member of __builtins__ when running:
> print(__import__("__main__").__dict__.keys()), rather then just
> showing __builtins__.
Oleg.
--
Oleg Broytman http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-Dev
mailing list