alternating the builtin functions
Jeff Epler
jepler at unpythonic.net
Sun Oct 19 09:56:15 EDT 2003
$ python
>>> print __builtins__
<module '__builtin__' (built-in)>
$ python -c 'print __builtins__'
$ echo 'print __builtins__ ' > m.py
$ python -c 'import m'
[contents of a dictionary]
For some reason, __builtins__ has long been a different thing in
__main__ than in any other module. To get consistent behavior, use
'import __builtin__' (that's always a module).
I think that the behavior/definition/value of __builtins__ is considered
an implementation detail. The closest I found to an admission of this
fact was here:
http://python.org/doc/ref/exec.html#l2h-563
Jeff
More information about the Python-list
mailing list