[Python-Dev] Fast access to __builtins__

Guido van Rossum guido@python.org
Fri, 28 Mar 2003 07:26:54 -0500


> > I'd be happy to proclaim that doing something like
> > 
> >   import X
> >   d = X.__dict__
> >   d["spam"] = 42    # or  exec "spam = 42" in d 
> > 
> > is always prohibited.
> 
> That would break lazy module imports such as the one I'm using
> in mx.Misc.LazyModule.py.

But you could rewrite LazyModule.py to use setattr(X, "spam", 42), right?

I don't think it's worth it to have a dict proxy that allows certain
keys to be set but not others.

--Guido van Rossum (home page: http://www.python.org/~guido/)