blob: 222bc408faf60ff89eb3bf38ea39e01577de3dbf [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001Built-in Constants
2==================
3
4A small number of constants live in the built-in namespace. They are:
5
6
7.. data:: False
8
9 The false value of the :class:`bool` type.
10
11 .. versionadded:: 2.3
12
13
14.. data:: True
15
16 The true value of the :class:`bool` type.
17
18 .. versionadded:: 2.3
19
20
21.. data:: None
22
23 The sole value of :attr:`types.NoneType`. ``None`` is frequently used to
24 represent the absence of a value, as when default arguments are not passed to a
25 function.
26
Georg Brandlb19be572007-12-29 10:57:00 +000027 .. versionchanged:: 2.4
28 Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`.
29
Georg Brandl8ec7f652007-08-15 14:28:01 +000030
31.. data:: NotImplemented
32
33 Special value which can be returned by the "rich comparison" special methods
34 (:meth:`__eq__`, :meth:`__lt__`, and friends), to indicate that the comparison
35 is not implemented with respect to the other type.
36
37
38.. data:: Ellipsis
39
40 Special value used in conjunction with extended slicing syntax.
41
Georg Brandlb19be572007-12-29 10:57:00 +000042 .. XXX Someone who understands extended slicing should fill in here.
Georg Brandl8ec7f652007-08-15 14:28:01 +000043
Georg Brandlb19be572007-12-29 10:57:00 +000044
45.. data:: __debug__
46
47 This constant is true if Python was not started with an :option:`-O` option.
48 Assignments to :const:`__debug__` are illegal and raise a :exc:`SyntaxError`.
Georg Brandl92058d22008-01-20 13:08:37 +000049 See also the :keyword:`assert` statement.
50
51
52Constants added by the :mod:`site` module
53-----------------------------------------
54
55The :mod:`site` module (which is imported automatically during startup, except
56if the :option:`-S` command-line option is given) adds several constants to the
57built-in namespace. They are useful for the interactive interpreter shell and
58should not be used in programs.
59
60.. data:: quit([code=None])
61 exit([code=None])
62
63 Objects that when printed, print a message like "Use quit() or Ctrl-D
64 (i.e. EOF) to exit", and when called, raise :exc:`SystemExit` with the
65 specified exit code, and when .
66
67.. data:: copyright
68 license
69 credits
70
71 Objects that when printed, print a message like "Type license() to see the
72 full license text", and when called, display the corresponding text in a
73 pager-like fashion (one screen at a time).