blob: 387087417e615f38e34a999fc5764c81f8dbb7b8 [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
Christian Heimes5b5e81c2007-12-31 16:14:33 +000018 The false value of the :class:`bool` type. Assignments to ``False``
19 are illegal and raise a :exc:`SyntaxError`.
Georg Brandl116aa622007-08-15 14:28:22 +000020
Georg Brandl116aa622007-08-15 14:28:22 +000021
22.. data:: True
23
Christian Heimes5b5e81c2007-12-31 16:14:33 +000024 The true value of the :class:`bool` type. Assignments to ``True``
25 are illegal and raise a :exc:`SyntaxError`.
Georg Brandl116aa622007-08-15 14:28:22 +000026
Georg Brandl116aa622007-08-15 14:28:22 +000027
28.. data:: None
29
30 The sole value of :attr:`types.NoneType`. ``None`` is frequently used to
31 represent the absence of a value, as when default arguments are not passed to a
Christian Heimes5b5e81c2007-12-31 16:14:33 +000032 function. Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`.
Georg Brandl116aa622007-08-15 14:28:22 +000033
34
35.. data:: NotImplemented
36
37 Special value which can be returned by the "rich comparison" special methods
38 (:meth:`__eq__`, :meth:`__lt__`, and friends), to indicate that the comparison
39 is not implemented with respect to the other type.
40
41
42.. data:: Ellipsis
43
44 The same as ``...``. Special value used mostly in conjunction with extended
Georg Brandlcb8ecb12007-09-04 06:35:14 +000045 slicing syntax for user-defined container data types, as in ::
Georg Brandl116aa622007-08-15 14:28:22 +000046
Christian Heimes5b5e81c2007-12-31 16:14:33 +000047 .. XXX Someone who understands extended slicing should fill in here.
Georg Brandl96593ed2007-09-07 14:15:41 +000048
49
50.. data:: __debug__
51
Christian Heimes5b5e81c2007-12-31 16:14:33 +000052 This constant is true if Python was not started with an :option:`-O` option.
53 Assignments to :const:`__debug__` are illegal and raise a :exc:`SyntaxError`.
54 See also the :keyword:`assert` statement.