[Python-Dev] [poll] New name for __builtins__

Jason Orendorff jason.orendorff at gmail.com
Fri Nov 30 01:05:26 CET 2007


On Nov 29, 2007 11:54 AM, Guido van Rossum <guido at python.org> wrote:
> But then I thought, what if we renamed the __builtin__ module instead
> to builtins, and left __builtins__ alone?

Hmm.  __builtins__ is a magic hook, but __builtin__-the-module isn't
the thing it hooks, exactly, not the way __import__ hooks import or
__iter__ hooks iter().  Really the __builtin__ module *implements* the
__builtins__ hook protocol.  It would be cool to have a name for
__builtin__ the module that suggests that.

I suggest sys.builtins.  The builtins module feels both central enough
and magical enough to belong in sys.  And a lot of other stuff in sys
has the same "it's fun but slightly crazy to tweak this knob" vibe.
And, for sandboxers, mysandbox.builtins seems like a nice parallel to
sys.builtins, with "sys" serving the bonus role of suggesting
"unrestricted access".

-j


More information about the Python-Dev mailing list