| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | Built-in Constants | 
 | 2 | ================== | 
 | 3 |  | 
 | 4 | A small number of constants live in the built-in namespace.  They are: | 
 | 5 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 6 | .. data:: False | 
 | 7 |  | 
| Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 8 |    The false value of the :class:`bool` type. Assignments to ``False`` | 
| Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 9 |    are illegal and raise a :exc:`SyntaxError`. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 10 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 11 |  | 
 | 12 | .. data:: True | 
 | 13 |  | 
| Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 14 |    The true value of the :class:`bool` type. Assignments to ``True`` | 
| Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 15 |    are illegal and raise a :exc:`SyntaxError`. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 16 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 17 |  | 
 | 18 | .. data:: None | 
 | 19 |  | 
 | 20 |    The sole value of :attr:`types.NoneType`.  ``None`` is frequently used to | 
 | 21 |    represent the absence of a value, as when default arguments are not passed to a | 
| Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 22 |    function. Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 23 |  | 
 | 24 |  | 
 | 25 | .. data:: NotImplemented | 
 | 26 |  | 
 | 27 |    Special value which can be returned by the "rich comparison" special methods | 
 | 28 |    (:meth:`__eq__`, :meth:`__lt__`, and friends), to indicate that the comparison | 
 | 29 |    is not implemented with respect to the other type. | 
 | 30 |  | 
 | 31 |  | 
 | 32 | .. data:: Ellipsis | 
 | 33 |  | 
| Georg Brandl | 9499bb7 | 2010-08-02 19:35:06 +0000 | [diff] [blame] | 34 |    The same as ``...``.  Special value used mostly in conjunction with extended | 
 | 35 |    slicing syntax for user-defined container data types. | 
| Georg Brandl | 96593ed | 2007-09-07 14:15:41 +0000 | [diff] [blame] | 36 |  | 
 | 37 |  | 
 | 38 | .. data:: __debug__ | 
 | 39 |  | 
| Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 40 |    This constant is true if Python was not started with an :option:`-O` option. | 
| Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 41 |    See also the :keyword:`assert` statement. | 
| Christian Heimes | 9bd667a | 2008-01-20 15:14:11 +0000 | [diff] [blame] | 42 |  | 
| Georg Brandl | 0c7ade2 | 2010-08-02 19:39:17 +0000 | [diff] [blame] | 43 |  | 
| Georg Brandl | c589a70 | 2010-08-02 19:36:36 +0000 | [diff] [blame] | 44 | .. note:: | 
 | 45 |  | 
 | 46 |    The names :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` | 
 | 47 |    cannot be reassigned (assignments to them, even as an attribute name, raise | 
 | 48 |    :exc:`SyntaxError`), so they can be considered "true" constants. | 
 | 49 |  | 
| Christian Heimes | 9bd667a | 2008-01-20 15:14:11 +0000 | [diff] [blame] | 50 |  | 
 | 51 | Constants added by the :mod:`site` module | 
 | 52 | ----------------------------------------- | 
 | 53 |  | 
 | 54 | The :mod:`site` module (which is imported automatically during startup, except | 
 | 55 | if the :option:`-S` command-line option is given) adds several constants to the | 
 | 56 | built-in namespace.  They are useful for the interactive interpreter shell and | 
 | 57 | should not be used in programs. | 
 | 58 |  | 
| Georg Brandl | c2a4f4f | 2009-04-10 09:03:43 +0000 | [diff] [blame] | 59 | .. data:: quit(code=None) | 
 | 60 |           exit(code=None) | 
| Christian Heimes | 9bd667a | 2008-01-20 15:14:11 +0000 | [diff] [blame] | 61 |  | 
 | 62 |    Objects that when printed, print a message like "Use quit() or Ctrl-D | 
 | 63 |    (i.e. EOF) to exit", and when called, raise :exc:`SystemExit` with the | 
| Benjamin Peterson | 8719ad5 | 2009-09-11 22:24:02 +0000 | [diff] [blame] | 64 |    specified exit code. | 
| Christian Heimes | 9bd667a | 2008-01-20 15:14:11 +0000 | [diff] [blame] | 65 |  | 
 | 66 | .. data:: copyright | 
 | 67 |           license | 
 | 68 |           credits | 
 | 69 |  | 
 | 70 |    Objects that when printed, print a message like "Type license() to see the | 
 | 71 |    full license text", and when called, display the corresponding text in a | 
 | 72 |    pager-like fashion (one screen at a time). | 
 | 73 |  |