python - why __builtins__ is both module and dict -
I am using built-in modules to insert some cases, so they are accessed globally for debugging purposes can be done. The problem with the __Biltions __
module is that it is a module in a main script and there is a word in the module, but depending on the cases my script may be the main script or module, I have to It:
ifinstance (__biltins_, dict): __biltions __ ['g_frame'] = 'xxx' Other: settings (__biltins__, 'g_frame', 'xxx')
Is there a lesser measure than this? More importantly, why does __biltions___
behave like this?
This is a script to see. Create a module. A.py: # module- an import b print 'a-builtin:', type (__pinned pin)
Create a module B.PO:
# module -b print 'b-builtin:', type (__bidden pin)
Now run python
> $ python a.py b-builtin: & lt; Type 'dict' & gt; A-Biltine: & lt; Type 'module' & gt;
I think you want __ builtin__
Modules (see Note:
CPython implementation details: The name of most modules is
__biltions __
(Note'
) made available as part of your world. The value of__Biltions __
is usually or module or this module [sic]__Vinicial___
is the value of the attribute. Since it is an implementation scale Is, it can not be done by alternative implementation of Python.
Comments
Post a Comment