Newbie namespace question

Peter Hansen peter at engcorp.com
Wed Dec 22 17:06:42 CET 2004


Steve Holden wrote:
> then in some other module (and here specifically in the interactive 
> interpreter) you can bind a value to "myname" in __builtins__ and it 
> will be seen by mymod.py when it's imported:
> 
>  >>> __builtins__.myname = "MyValue"

Steve's basic premise is correct, but he's chosen the wrong
name to use.  As Fredrik Lundh has written here 
http://mail.python.org/pipermail/python-list/2002-June/109090.html
the name above is an implementation detail and one should
always do this instead:

import __builtin__
__builtin__.myname = "MyValue"

And doing so reinforces the idea that this is Almost Always
a Bad Idea.  :-)

-Peter



More information about the Python-list mailing list