[Python-3000] __builtin__ and __builtins__
Greg Ewing
greg.ewing at canterbury.ac.nz
Mon Mar 12 23:12:07 CET 2007
Ka-Ping Yee wrote:
> We have "import as", though. If you want to import the default
> builtins without using them as the builtins, you can say
>
> import __builtin__ as default_builtin
Seems to me it would be better to rename the module
to a non-double-underscore name. There's really nothing
magical about the module itself, only the name used
by global variable lookups. So just call the module
'builtins', and then you can do
import builtins # get the module with no magic happening
import mystuff as __builtins__ # change my builtin namespace
import builtins as __builtins__ # restore default builtin namespace
--
Greg
More information about the Python-3000
mailing list