내장 상수¶
작은 개수의 상수가 내장 이름 공간에 있습니다. 그것들은:
- False¶
bool형의 거짓 값.False에 대입할 수 없고SyntaxError를 일으킵니다.
- True¶
bool형의 참값.True에 대입할 수 없고SyntaxError를 일으킵니다.
- None¶
기본 인자가 함수에 전달되지 않을 때처럼, 값의 부재를 나타내는 데 자주 사용되는 객체.
None으로의 대입은 허락되지 않고SyntaxError를 일으킵니다.None은NoneType형의 유일한 인스턴스입니다.
- NotImplemented¶
연산이 다른 형에 대해 구현되지 않았음을 나타내기 위해, 이 항 특수 메서드(예를 들어,
__eq__(),__lt__(),__add__(),__rsub__()등)가 돌려줘야 하는 특별한 값; 같은 목적으로 증분 이 항 특수 메서드(예를 들어,__imul__(),__iand__()등)가 반환할 수 있습니다. 불리언 문맥에서 평가해서는 안됩니다.NotImplemented는types.NotImplementedType형의 유일한 인스턴스입니다.참고
이 항 (또는 증분) 메서드가
NotImplemented를 반환하면 인터프리터는 다른 형(또는 연산자에 따라 다른 폴백)에서 뒤집힌 연산을 시도합니다. 모든 시도가NotImplemented를 반환하면, 인터프리터는 적절한 예외를 발생시킵니다. 부정확하게NotImplemented를 반환하면 오해의 소지가 있는 에러 메시지가 나오거나 파이썬 코드에NotImplemented값이 반환됩니다.예는 산술 연산 구현을 보세요.
조심
NotImplementedError와NotImplemented는 바꿔쓸 수 없습니다. 이 상수는 위에서 설명한 대로만 사용해야 합니다; 이 예외의 올바른 사용법에 대한 자세한 내용은NotImplementedError를 참조하세요.버전 3.9에서 변경: Evaluating
NotImplementedin a boolean context was deprecated.버전 3.14에서 변경: Evaluating
NotImplementedin a boolean context now raises aTypeError. It previously evaluated toTrueand emitted aDeprecationWarningsince Python 3.9.
- Ellipsis¶
The same as the ellipsis literal “
...”, an object frequently used to indicate that something is omitted. Assignment toEllipsisis possible, but assignment to...raises aSyntaxError.Ellipsisis the sole instance of thetypes.EllipsisTypetype.
참고
None, False, True 그리고 __debug__ 은 다시 대입할 수 없습니다 (이것들을 대입하면, 설사 어트리뷰트 이름으로 사용해도, SyntaxError 를 일으킵니다). 그래서 이것들은 “진짜” 상수로 간주 될 수 있습니다.
site 모듈에 의해 추가된 상수들¶
site 모듈(-S 명령행 옵션이 주어진 경우를 제외하고는, 시작할 때 자동으로 임포트 됩니다)은 내장 이름 공간에 여러 상수를 추가합니다. 대화형 인터프리터 셸에 유용하고 프로그램에서 사용해서는 안 됩니다.
- quit(code=None)¶
- exit(code=None)¶
Objects that when printed, print a message like “Use quit() or Ctrl-D (i.e. EOF) to exit”, and when accessed directly in the interactive interpreter or called as functions, raise
SystemExitwith the specified exit code.
- help
Object that when printed, prints the message “Type help() for interactive help, or help(object) for help about object.”, and when accessed directly in the interactive interpreter, invokes the built-in help system (see
help()).
- license¶
인쇄될 때 “Type license() to see the full license text”와 같은 메시지를 인쇄하고, 호출될 때 전체 라이센스 텍스트를 페이지 생성기와 같은 방식(한 번에 한 화면씩)으로 표시하는 객체입니다.