python namespce 之built-in namespce

  • namespace
  • __builtin__ module

namespace

python的namespace主要就是一个从标识符到对象的字典。global namespace 指某个模块的全局名字。local namespace 指某个函数的本地名字。还有一个名字空间就是built-in namespce,指内置模块(__buildin__)的global namespace。

A namespace is a mapping from names to objects. Most namespaces are currently implemented as Python dictionaries, but that’s normally not noticeable in any way (except for performance), and it may change in the future. Examples of namespaces are: the set of built-in names (containing functions such as abs(), and built-in exception names); the global names in a module; and the local names in a function invocation.Python Scopes and Namespaces

__builtin__ module

这个总是容易和built-in modules傻傻分不清。
This module provides direct access to all ‘built-in’ identifiers of Python;
__builtin__ \— Built-in objects

而built-in modules则是指那些内置的的模块(都是用c语言实现的)。
The library contains built-in modules (written in C) that provide access to system functionality such as file I/O that would otherwise be inaccessible to Python programmers.
built-in modules

所以__builtin__ module只是built-in modules中的一个。

你可能感兴趣的:(python)