cpython/Doc/library/constants.rst

79 lines
2.4 KiB
ReStructuredText
Raw Normal View History

2007-08-15 11:28:22 -03:00
Built-in Constants
==================
A small number of constants live in the built-in namespace. They are:
.. note::
:data:`None`, :data:`False`, :data:`True` and :data:`__debug__` cannot be
2007-12-29 06:57:11 -04:00
reassigned (assignments to them raise :exc:`SyntaxError`), so they can be
considered "true" constants.
.. XXX False, True, None are keywords too
2007-08-15 11:28:22 -03:00
.. data:: False
The false value of the :class:`bool` type. Assignments to ``False``
are illegal and raise a :exc:`SyntaxError`.
2007-08-15 11:28:22 -03:00
.. data:: True
The true value of the :class:`bool` type. Assignments to ``True``
are illegal and raise a :exc:`SyntaxError`.
2007-08-15 11:28:22 -03:00
.. data:: None
The sole value of :attr:`types.NoneType`. ``None`` is frequently used to
represent the absence of a value, as when default arguments are not passed to a
function. Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`.
2007-08-15 11:28:22 -03:00
.. data:: NotImplemented
Special value which can be returned by the "rich comparison" special methods
(:meth:`__eq__`, :meth:`__lt__`, and friends), to indicate that the comparison
is not implemented with respect to the other type.
.. data:: Ellipsis
The same as ``...``. Special value used mostly in conjunction with extended
2007-09-04 03:35:14 -03:00
slicing syntax for user-defined container data types, as in ::
2007-08-15 11:28:22 -03:00
.. XXX Someone who understands extended slicing should fill in here.
.. data:: __debug__
This constant is true if Python was not started with an :option:`-O` option.
Assignments to :const:`__debug__` are illegal and raise a :exc:`SyntaxError`.
See also the :keyword:`assert` statement.
Merged revisions 60124-60142 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60131 | georg.brandl | 2008-01-20 12:13:29 +0100 (Sun, 20 Jan 2008) | 3 lines #1351692: in pprint, always call format() for dict and list items to enable custom formatting of contents via subclassing PrettyPrinter. ........ r60133 | georg.brandl | 2008-01-20 12:43:03 +0100 (Sun, 20 Jan 2008) | 2 lines #1178141: add addinfourl.code to get http status code from urllib. ........ r60134 | georg.brandl | 2008-01-20 13:05:43 +0100 (Sun, 20 Jan 2008) | 4 lines #856047: respect the ``no_proxy`` env var when checking for proxies in urllib and using the other ``_proxy`` env vars. Original patch by Donovan Baarda. ........ r60135 | georg.brandl | 2008-01-20 13:18:17 +0100 (Sun, 20 Jan 2008) | 4 lines #1664522: in urllib, don't read non-existing directories in ftp mode, returning a 0-byte file -- raise an IOError instead. Original patch from Phil Knirsch. ........ r60136 | georg.brandl | 2008-01-20 13:57:47 +0100 (Sun, 20 Jan 2008) | 2 lines #799369: document possible sys.platform values. ........ r60137 | georg.brandl | 2008-01-20 14:08:37 +0100 (Sun, 20 Jan 2008) | 2 lines #652749: document the constants added to the builtins by site.py. ........ r60138 | georg.brandl | 2008-01-20 14:59:46 +0100 (Sun, 20 Jan 2008) | 2 lines #1648: add sys.gettrace() and sys.getprofile(). ........ r60139 | georg.brandl | 2008-01-20 15:17:42 +0100 (Sun, 20 Jan 2008) | 2 lines #1669: don't allow shutil.rmtree() to be called on a symlink. ........ r60140 | georg.brandl | 2008-01-20 15:20:02 +0100 (Sun, 20 Jan 2008) | 2 lines Fix test_pyclbr after urllib change. ........ r60141 | christian.heimes | 2008-01-20 15:28:28 +0100 (Sun, 20 Jan 2008) | 1 line Fixed a wrong assumption in configure.in and Include/pyport.h. The is finite function is not called isfinite() but finite(). Sorry, my fault. :) ........ r60142 | georg.brandl | 2008-01-20 15:31:27 +0100 (Sun, 20 Jan 2008) | 2 lines #1876: fix typos in test_operator. ........
2008-01-20 11:14:11 -04:00
Constants added by the :mod:`site` module
-----------------------------------------
The :mod:`site` module (which is imported automatically during startup, except
if the :option:`-S` command-line option is given) adds several constants to the
built-in namespace. They are useful for the interactive interpreter shell and
should not be used in programs.
.. data:: quit([code=None])
exit([code=None])
Objects that when printed, print a message like "Use quit() or Ctrl-D
(i.e. EOF) to exit", and when called, raise :exc:`SystemExit` with the
specified exit code, and when .
.. data:: copyright
license
credits
Objects that when printed, print a message like "Type license() to see the
full license text", and when called, display the corresponding text in a
pager-like fashion (one screen at a time).