python同名函数相互冲突_python3(python3.1、python3k、python3000)中两个相互冲突的内置函数含义...

我刚把下面的问题发到编译lang.python,但我觉得这种问题在堆栈溢出问题上也有一定的方法,所以请重复。要点:为什么python3中的builtins有两种不同的解释?在

我很乐意接受任何关于这件事的评论

从http://celabs.com/python-3.1/reference/executionmodel.html收集的句子,

是为了卑鄙,或者为什么上帝决定这是一条路。我

估计这个叫凯·施鲁厄的人会有发言权,或者

也许即使是BDFL也会介意发__builtins__the

正确对待他的追随者、追随者和同僚们:The built-in namespace associated with the execution of

a code block is actually found by looking up the name

__builtins__ in its global namespace; this should be a

dictionary or a module (in the latter case the module’s

dictionary is used). By default, when in the __main__

module, __builtins__ is the built-in module builtins;

when in any other module, __builtins__ is an alias for

the dictionary of the builtins module itself.

__builtins__ can be set to a user-created dictionary to

create a weak form of restricted execution.

过去至少有两个不同的术语,

“builtin”(单数)和“builtins”(复数),其中一些

它以模块和dict形式存在(?)?猜猜看。现在

只有builtins,所以幸运的是

单数和复数已经很好地摆脱了。在

但为什么__builtins__会根据

这是“脚本”(即名称为的模块)的范围

当调用python foobar.py)时出现,或者这是否是

辅助模块的范围(直接导入或执行,或

{cd5>间接?我不明白其中的道理

在这背后,我发现它非常令人困惑。在

理由:我为什么在乎?-我想把名字导出到

未标记为私有的全局命名空间(通过下划线

prefix)在我通过exec( compile( get

( locator ), locator, 'exec' ), R )执行的python模块中,R应该去的地方

持有所述模块的私人名称。它有点神秘但是

基本练习是绕过python的导入系统并获得similr

结果。。。这就是把名字注入到全球

模块全局命名空间。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值