Issue 4582: type of builtins changes if in main module or not (original) (raw)

Issue4582

Created on 2008-12-07 20:48 by nnorwitz, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg77252 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2008-12-07 20:48
This happens on 2.4 and 3.0, probably all versions: When running this simple program (save to a file): print(type(__builtins__)) __import__(__file__.split('/')[-1][:-3]) I get: <type 'module'> <type 'dict'> I would expect the type to be consistent regardless of whether executing the main module or from the imported module. I haven't looked into why this is happening or if it makes sense. It was unexpected.
msg77254 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-12-07 20:57
This is documented, intentional behavior: http://docs.python.org/library/__builtin__.html?highlight=__builtins__
History
Date User Action Args
2022-04-11 14:56:42 admin set github: 48832
2008-12-07 20:57:07 loewis set status: open -> closedresolution: wont fixmessages: + nosy: + loewis
2008-12-07 20:48:38 nnorwitz create