내장 상수

작은 개수의 상수가 내장 이름 공간에 있습니다. 그것들은:

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 a SyntaxError. None is the sole instance of the NoneType 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 the types.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 return NotImplemented, the interpreter will raise an appropriate exception. Incorrectly returning NotImplemented will result in a misleading error message or the NotImplemented value being returned to Python code.

예는 산술 연산 구현을 보세요.

참고

NotImplementedError and NotImplemented are not interchangeable, even though they have similar names and purposes. See NotImplementedError for details on when to use it.

버전 3.9에서 변경: Evaluating NotImplemented in a boolean context is deprecated. While it currently evaluates as true, it will emit a DeprecationWarning. It will raise a TypeError 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 the types.EllipsisType type.

__debug__

이 상수는 파이썬이 -O 옵션으로 시작되지 않았다면 참이 됩니다. assert 문도 볼 필요가 있습니다.

참고

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 를 일으키는 객체.

credits

인쇄하거나 호출할 때, 각각 저작권 또는 크레딧 텍스트를 인쇄하는 객체입니다.

license

인쇄될 때 “Type license() to see the full license text”와 같은 메시지를 인쇄하고, 호출될 때 전체 라이센스 텍스트를 페이지 생성기와 같은 방식(한 번에 한 화면씩)으로 표시하는 객체입니다.