Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | |
| 2 | Built-in Constants |
| 3 | ================== |
| 4 | |
| 5 | A small number of constants live in the built-in namespace. They are: |
| 6 | |
| 7 | |
Georg Brandl | 96593ed | 2007-09-07 14:15:41 +0000 | [diff] [blame] | 8 | .. note:: |
| 9 | |
| 10 | :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` cannot be |
| 11 | reassigned, so they can be considered "true" constants. |
| 12 | |
Georg Brandl | 55ac8f0 | 2007-09-01 13:51:09 +0000 | [diff] [blame] | 13 | .. XXX False, True, None are keywords too |
| 14 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 15 | .. data:: False |
| 16 | |
| 17 | The false value of the :class:`bool` type. |
| 18 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 19 | |
| 20 | .. data:: True |
| 21 | |
| 22 | The true value of the :class:`bool` type. |
| 23 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 24 | |
| 25 | .. data:: None |
| 26 | |
| 27 | The sole value of :attr:`types.NoneType`. ``None`` is frequently used to |
| 28 | represent the absence of a value, as when default arguments are not passed to a |
| 29 | function. |
| 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 | The same as ``...``. Special value used mostly in conjunction with extended |
Georg Brandl | cb8ecb1 | 2007-09-04 06:35:14 +0000 | [diff] [blame] | 42 | slicing syntax for user-defined container data types, as in :: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 43 | |
Georg Brandl | cb8ecb1 | 2007-09-04 06:35:14 +0000 | [diff] [blame] | 44 | val = container[1:5, 7:10, ...] |
Georg Brandl | 96593ed | 2007-09-07 14:15:41 +0000 | [diff] [blame] | 45 | |
| 46 | |
| 47 | .. data:: __debug__ |
| 48 | |
| 49 | A boolean value that is :data:`True` if Python was not started with the |
| 50 | ``-O`` command line option. Its value is used indirectly by the |
| 51 | :keyword:`assert` statement, but it can also be used directly in code. |