471,325 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Why does __builtins__ mean different things...

Hello all,

Say I have the following module

# amodule.py
print __builtins__
# end of module

Then I have the following little helper script:

# helper.py
import amodule
# end of helper script

Now, I do this at the command line:

python amodule.py

And I get the following output:

<module '__builtin__' (built-in)>

Which is good.

Now, I do this:

python helper.py

and I get the following output:

{'IndexError': <type 'exceptions.IndexError'>, 'all;:
.... [etc]

I.e.: __builtins__ is a dict when referenced in an imported module, but
in *the exact same code*, when executed as a script, it becomes a
module! Is this a bug?

In other words, what is the good of this? For the purposes of argument,
the bad of this is the behavior above. I'm guessing its a bug.

James
Dec 20 '07 #1
0 817

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Michael Hohn | last post: by
21 posts views Thread by Michael Hoffman | last post: by
4 posts views Thread by Collin Winter | last post: by
13 posts views Thread by Jason Huang | last post: by
3 posts views Thread by loquehumaine | last post: by
reply views Thread by Patrick Maupin | last post: by
3 posts views Thread by Gabriel Genellina | last post: by
reply views Thread by Lie Ryan | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.