内置名称空间有存活少量常量。它们是:
False
¶
False 值的
bool
类型。赋值
False
是非法的且会引发
SyntaxError
.
True
¶
True 值的
bool
类型。赋值
True
是非法的且会引发
SyntaxError
.
None
¶
唯一值对于类型
NoneType
.
None
is frequently used to represent the absence of a value, as when default arguments are not passed to a function. Assignments to
None
是非法的且会引发
SyntaxError
.
NotImplemented
¶
Special value which should be returned by the binary special methods (e.g.
__eq__()
,
__lt__()
,
__add__()
,
__rsub__()
,等) 指示操作不是为其它类型方面而实现的;可以返回通过原位二进制特殊方法 (如
__imul__()
,
__iand__()
, etc.) for the same purpose. Its truth value is true.
注意
当二进制 (或原位) 方法返回
NotImplemented
解释器将试着反映其它类型的操作 (或一些其它回退,从属运算符)。若所有尝试返回
NotImplemented
,解释器会引发适当异常。不正确返回
NotImplemented
会产生误导性错误消息或
NotImplemented
值被返回给 Python 代码。
见 实现算术运算 范例。
注意
NotImplementedError
and
NotImplemented
不可互换,即使它们拥有相似的名称和用途。见
NotImplementedError
了解使用时的有关细节。
Ellipsis
¶
如同省略文字
...
。特殊值主要用于结合用户定义的容器数据类型的扩展切片句法。
__debug__
¶
此常量为 True 若 Python 未启动采用
-O
选项。另请参阅
assert
语句。
注意
名称
None
,
False
,
True
and
__debug__
无法重新赋值 (赋值它们,即使作为属性名称,引发
SyntaxError
),所以它们可以被认为是真常量。
site
模块
¶
The
site
模块 (在启动期间被自动导入,除了若
-S
命令行选项有给定) 将几个常量添加到内置名称空间。它们很有用对于交互解释器 Shell,且不应用于程序中。
quit
(
code=None
)
¶
exit
(
code=None
)
¶
对象当打印时,打印消息像 "Use quit() or Ctrl-D (i.e. EOF) to exit",和当调用时,引发
SystemExit
采用指定退出代码。
license
¶
对象当打印时,打印消息 "Type license() to see the full license text",和当调用时,以像分页程序的方式 (每次一屏) 显示完整许可文本。