[Doc-SIG] Finding cannonical names for objects
Fred L. Drake, Jr.
fdrake@acm.org
Sun, 22 Apr 2001 01:21:42 -0400 (EDT)
Edward D. Loper writes:
> Ok. I guess maybe my question should have been why the default global
> (?) variable to access them is called "__builtins__" rather than
> "__builtin__"::
__builtins__ is an implementation detail, nothing more. It is used
to obtain the built-in functions; for all namespaces other than
__main__, __builtins__ is a dictionary rather than a module. The
identity of the __builtins__ dict is also used to determine if code is
running in restricted execution mode; if the name bound to
__builtins__ is not the __builtin__ module or the dictionary for that
module, the restricted execution rules are in place. The name is
different so it doesn't clash, and allows a minor performance
improvement over using the __builtin__ module when accessing the
built-in namespace.
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Digital Creations