Adam Hupp <[EMAIL PROTECTED]> wrote: > I've noticed some unexpected behavior with __builtins__ during module > import. It seems that during module import __builtins__ is a dict > but at all other times it is a module. > > For example, if the file testmod.py has these contents: > > print type(__builtins__) > print "has str attr", hasattr(__builtins__, 'str') > > The output differs depending on how it is run: > > $ python ~/testmod.py > <type 'module'> > has str True > > vs. > > $ python -c 'import testmod' > <type 'dict'> > has str False > > Anyone know if there a reason for this behavior? Is it a bug? I've > seen this in 2.4 and 3.0. > > -Adam
No, it's not a bug. __builtins__ is an implementation detail. You want __builtin__. See <http://docs.python.org/lib/module-builtin.html> Ciao Marc -- http://mail.python.org/mailman/listinfo/python-list