whassup? builtins? python3000? Naah can't be right?

Terry Reedy tjreedy at udel.edu
Sun Jan 31 22:20:52 EST 2010


On 1/31/2010 4:17 PM, _wolf wrote:

> but why does ``__builtins__`` change its meaning depending on whether
> this is the scope of the ‘script’ (i.e. the module whose name was
> present, when calling ``python foobar.py``) or whether this is the
> scope of a secondary module (imported or executed, directly or
> indirectly, by ``foobar.py``)?

There is a technical reason, which I believe Guido once gave in a post 
to the now-closed py3k list as part of the thread on the change to a 
single name. I do not remember, but I presume it has something to do 
with a difference between executing the main module and imported 
modules. Rest assured that it is intentional and has a reason. You can, 
of course, check if __name__ == '__main__': to know how to access.

Terry Jan Reedy





More information about the Python-list mailing list