blob: 80e792c9521d7fda0233ca14ff63b57509ce9745 [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
Georg Brandl8ec7f652007-08-15 14:28:01 +00006.. data:: False
7
8 The false value of the :class:`bool` type.
9
10 .. versionadded:: 2.3
11
12
13.. data:: True
14
15 The true value of the :class:`bool` type.
16
17 .. versionadded:: 2.3
18
19
20.. data:: None
21
22 The sole value of :attr:`types.NoneType`. ``None`` is frequently used to
23 represent the absence of a value, as when default arguments are not passed to a
24 function.
25
Georg Brandlb19be572007-12-29 10:57:00 +000026 .. versionchanged:: 2.4
27 Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`.
28
Georg Brandl8ec7f652007-08-15 14:28:01 +000029
30.. data:: NotImplemented
31
32 Special value which can be returned by the "rich comparison" special methods
33 (:meth:`__eq__`, :meth:`__lt__`, and friends), to indicate that the comparison
34 is not implemented with respect to the other type.
35
36
37.. data:: Ellipsis
38
39 Special value used in conjunction with extended slicing syntax.
40
Georg Brandlb19be572007-12-29 10:57:00 +000041
42.. data:: __debug__
43
44 This constant is true if Python was not started with an :option:`-O` option.
Georg Brandl92058d22008-01-20 13:08:37 +000045 See also the :keyword:`assert` statement.
46
47
Georg Brandl1858b6f2010-08-02 20:32:03 +000048.. note::
49
50 The names :data:`None` and :data:`__debug__` cannot be reassigned
51 (assignments to them, even as an attribute name, raise :exc:`SyntaxError`),
52 so they can be considered "true" constants.
53
54 .. versionchanged:: 2.7
55 Assignments to ``__debug__`` as an attribute became illegal.
56
57
Georg Brandl92058d22008-01-20 13:08:37 +000058Constants added by the :mod:`site` module
59-----------------------------------------
60
61The :mod:`site` module (which is imported automatically during startup, except
62if the :option:`-S` command-line option is given) adds several constants to the
63built-in namespace. They are useful for the interactive interpreter shell and
64should not be used in programs.
65
66.. data:: quit([code=None])
67 exit([code=None])
68
69 Objects that when printed, print a message like "Use quit() or Ctrl-D
70 (i.e. EOF) to exit", and when called, raise :exc:`SystemExit` with the
R. David Murraye7ba7422009-08-27 01:04:59 +000071 specified exit code.
Georg Brandl92058d22008-01-20 13:08:37 +000072
73.. data:: copyright
74 license
75 credits
76
77 Objects that when printed, print a message like "Type license() to see the
78 full license text", and when called, display the corresponding text in a
79 pager-like fashion (one screen at a time).