내장 상수¶
작은 개수의 상수가 내장 이름 공간에 있습니다. 그것들은:
- False¶
bool
형의 거짓 값.False
에 대입할 수 없고SyntaxError
를 일으킵니다.
- True¶
bool
형의 참값.True
에 대입할 수 없고SyntaxError
를 일으킵니다.
- None¶
An object frequently used to represent the absence of a value, as when default arguments are not passed to a function. Assignments to
None
are illegal and raise aSyntaxError
.None
is the sole instance of theNoneType
type.
- NotImplemented¶
A special value which should be returned by the binary special methods (e.g.
__eq__()
,__lt__()
,__add__()
,__rsub__()
, etc.) to indicate that the operation is not implemented with respect to the other type; may be returned by the in-place binary special methods (e.g.__imul__()
,__iand__()
, etc.) for the same purpose. It should not be evaluated in a boolean context.NotImplemented
is the sole instance of thetypes.NotImplementedType
type.참고
When a binary (or in-place) method returns
NotImplemented
the interpreter will try the reflected operation on the other type (or some other fallback, depending on the operator). If all attempts returnNotImplemented
, the interpreter will raise an appropriate exception. Incorrectly returningNotImplemented
will result in a misleading error message or theNotImplemented
value being returned to Python code.예는 산술 연산 구현을 보세요.
조심
NotImplemented
andNotImplementedError
are not interchangeable. This constant should only be used as described above; seeNotImplementedError
for details on correct usage of the exception.버전 3.9에서 변경: Evaluating
NotImplemented
in a boolean context is deprecated. While it currently evaluates as true, it will emit aDeprecationWarning
. It will raise aTypeError
in a future version of Python.
- Ellipsis¶
The same as the ellipsis literal “
...
”. Special value used mostly in conjunction with extended slicing syntax for user-defined container data types.Ellipsis
is the sole instance of thetypes.EllipsisType
type.
참고
None
, False
, True
그리고 __debug__
은 다시 대입할 수 없습니다 (이것들을 대입하면, 설사 어트리뷰트 이름으로 사용해도, SyntaxError
를 일으킵니다). 그래서 이것들은 “진짜” 상수로 간주 될 수 있습니다.
site
모듈에 의해 추가된 상수들¶
site
모듈(-S
명령행 옵션이 주어진 경우를 제외하고는, 시작할 때 자동으로 임포트 됩니다)은 내장 이름 공간에 여러 상수를 추가합니다. 대화형 인터프리터 셸에 유용하고 프로그램에서 사용해서는 안 됩니다.
- quit(code=None)¶
- exit(code=None)¶
인쇄될 때, “Use quit() or Ctrl-D (i.e. EOF) to exit”과 같은 메시지를 인쇄하고, 호출될 때, 지정된 종료 코드로
SystemExit
를 일으키는 객체.
- help
Object that when printed, prints the message “Type help() for interactive help, or help(object) for help about object.”, and when called, acts as described
elsewhere
.
- license¶
인쇄될 때 “Type license() to see the full license text”와 같은 메시지를 인쇄하고, 호출될 때 전체 라이센스 텍스트를 페이지 생성기와 같은 방식(한 번에 한 화면씩)으로 표시하는 객체입니다.