[Python-3000] __builtin__ and __builtins__
Ka-Ping Yee
python at zesty.ca
Mon Mar 12 08:17:33 CET 2007
On Mon, 12 Mar 2007, Greg Ewing wrote:
> Changing __main__ to match would seem to be a
> good idea.
[...]
> There might be merit in renaming __builtins__
> to something less confusable, at the expense of
> breaking existing code which refers to it.
Cool.
> I don't think it would be such a good
> idea to unify __builtin__ and __builtins__,
> because then importing __builtin__ would clobber
> the existing builtin namespace being used by
> the code -- which may not be the same thing.
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
If you want to reset the builtins to the default builtins:
import __builtin__
If you want to replace them with your own builtins:
import my_builtin as __builtin__
That doesn't seem so bad.
Hmm... when do you find yourself importing __builtin__?
-- ?!ng
More information about the Python-3000
mailing list