blob: 0d44b7babb5cfd86af10db64d2d22f90a63dc626 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001
2Built-in Constants
3==================
4
5A small number of constants live in the built-in namespace. They are:
6
7
Georg Brandl96593ed2007-09-07 14:15:41 +00008.. note::
9
10 :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` cannot be
Georg Brandl18a499d2007-12-29 10:57:11 +000011 reassigned (assignments to them raise :exc:`SyntaxError`), so they can be
12 considered "true" constants.
Georg Brandl96593ed2007-09-07 14:15:41 +000013
Georg Brandl55ac8f02007-09-01 13:51:09 +000014.. XXX False, True, None are keywords too
15
Georg Brandl116aa622007-08-15 14:28:22 +000016.. data:: False
17
18 The false value of the :class:`bool` type.
19
Georg Brandl116aa622007-08-15 14:28:22 +000020
21.. data:: True
22
23 The true value of the :class:`bool` type.
24
Georg Brandl116aa622007-08-15 14:28:22 +000025
26.. data:: None
27
28 The sole value of :attr:`types.NoneType`. ``None`` is frequently used to
29 represent the absence of a value, as when default arguments are not passed to a
30 function.
31
32
33.. data:: NotImplemented
34
35 Special value which can be returned by the "rich comparison" special methods
36 (:meth:`__eq__`, :meth:`__lt__`, and friends), to indicate that the comparison
37 is not implemented with respect to the other type.
38
39
40.. data:: Ellipsis
41
42 The same as ``...``. Special value used mostly in conjunction with extended
Georg Brandlcb8ecb12007-09-04 06:35:14 +000043 slicing syntax for user-defined container data types, as in ::
Georg Brandl116aa622007-08-15 14:28:22 +000044
Georg Brandlcb8ecb12007-09-04 06:35:14 +000045 val = container[1:5, 7:10, ...]
Georg Brandl96593ed2007-09-07 14:15:41 +000046
47
48.. data:: __debug__
49
50 A boolean value that is :data:`True` if Python was not started with the
51 ``-O`` command line option. Its value is used indirectly by the
52 :keyword:`assert` statement, but it can also be used directly in code.