• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. _built-in-consts:
2
3Built-in Constants
4==================
5
6A small number of constants live in the built-in namespace.  They are:
7
8.. data:: False
9
10   The false value of the :class:`bool` type.
11
12   .. versionadded:: 2.3
13
14
15.. data:: True
16
17   The true value of the :class:`bool` type.
18
19   .. versionadded:: 2.3
20
21
22.. data:: None
23
24   The sole value of :attr:`types.NoneType`.  ``None`` is frequently used to
25   represent the absence of a value, as when default arguments are not passed to a
26   function.
27
28   .. versionchanged:: 2.4
29      Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`.
30
31
32.. data:: NotImplemented
33
34   Special value which can be returned by the "rich comparison" special methods
35   (:meth:`__eq__`, :meth:`__lt__`, and friends), to indicate that the comparison
36   is not implemented with respect to the other type.
37
38
39.. data:: Ellipsis
40
41   Special value used in conjunction with extended slicing syntax.
42
43
44.. data:: __debug__
45
46   This constant is true if Python was not started with an :option:`-O` option.
47   See also the :keyword:`assert` statement.
48
49
50.. note::
51
52   The names :data:`None` and :data:`__debug__` cannot be reassigned
53   (assignments to them, even as an attribute name, raise :exc:`SyntaxError`),
54   so they can be considered "true" constants.
55
56   .. versionchanged:: 2.7
57      Assignments to ``__debug__`` as an attribute became illegal.
58
59
60Constants added by the :mod:`site` module
61-----------------------------------------
62
63The :mod:`site` module (which is imported automatically during startup, except
64if the :option:`-S` command-line option is given) adds several constants to the
65built-in namespace.  They are useful for the interactive interpreter shell and
66should not be used in programs.
67
68.. data:: quit([code=None])
69          exit([code=None])
70
71   Objects that when printed, print a message like "Use quit() or Ctrl-D
72   (i.e. EOF) to exit", and when called, raise :exc:`SystemExit` with the
73   specified exit code.
74
75.. data:: copyright
76          credits
77
78   Objects that when printed or called, print the text of copyright or
79   credits, respectively.
80
81.. data:: license
82
83   Object that when printed, prints the message "Type license() to see the
84   full license text", and when called, displays the full license text in a
85   pager-like fashion (one screen at a time).
86