[Python-Dev] Re: [Pythonmac-SIG] __builtins__ a dictionary or a module?

Jack Jansen jack@oratrix.nl
Fri, 06 Apr 2001 10:50:24 +0200


Python-devvers, can anyone help with this behaviour?

> If I run Just's Python IDE and run the same code it tells mes that
> __builtins__ is a module.
> 
> And finally if I run the following code from within the Interactive console
> contained in standard 'code.py' file I get told __builtins__ is a
> dictionary.
> 
> So what is it? Is __builtins__ a module or a dictionary? I know that they're
> essentially the same thing, but it unnerves me to have the same code produce
> different results in different platforms.

Well, I've narrowed down the difference to the exec statement:
>>> exec "print type(__builtins__)"
<type 'module'>
>>> exec "print type(__builtins__)" in {}
<type 'dictionary'>

Can anyone explain what is going on here?
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm