diff options
author | Skip Montanaro <skip@pobox.com> | 2004-03-27 18:23:11 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2004-03-27 18:23:11 (GMT) |
commit | dbb407808ac3c0ef9ca3585d3dadd4b7678286a8 (patch) | |
tree | 29fe45c32200f02828725ff88ac5bac3b6687d0a /Doc/tut | |
parent | d732c95eb0763bf4d5bb3f6e03707828185800bb (diff) | |
download | cpython-dbb407808ac3c0ef9ca3585d3dadd4b7678286a8.zip cpython-dbb407808ac3c0ef9ca3585d3dadd4b7678286a8.tar.gz cpython-dbb407808ac3c0ef9ca3585d3dadd4b7678286a8.tar.bz2 |
- add entry for complex number
- fix a couple typos
- refine definitions for "interpreted" and "coercion" based upon updates on
the python glossary wiki
Diffstat (limited to 'Doc/tut')
-rw-r--r-- | Doc/tut/glossary.tex | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/Doc/tut/glossary.tex b/Doc/tut/glossary.tex index 4702d67..8cf0949 100644 --- a/Doc/tut/glossary.tex +++ b/Doc/tut/glossary.tex @@ -37,13 +37,33 @@ Any class which does not inherit from \class{object}. See \index{coercion} \item[coercion] -Converting data from one type to another. For example, -{}\code{int(3.15)} coerces the floating point number to the integer, -{}\code{3}. Most mathematical operations have rules for coercing -their arguments to a common type. For instance, adding \code{3+4.5}, -causes the integer \code{3} to be coerced to be a float -{}\code{3.0} before adding to \code{4.5} resulting in the float -{}\code{7.5}. + +The implicit conversion of an instance of one type to another during an +operation which involves two arguments of the same type. For example, +{}\code{int(3.15)} converts the floating point number to the integer, +{}\code{3}, but in {}\code{3+4.5}, each argument is of a different type (one +int, one float), and both must be converted to the same type before they can +be added or it will raise a {}\code{TypeError}. Coercion between two +operands can be performed with the {}\code{coerce} builtin function; thus, +{}\code{3+4.5} is equivalent to calling {}\code{operator.add(*coerce(3, +4.5))} and results in {}\code{operator.add(3.0, 4.5)}. Without coercion, +all arguments of even compatible types would have to be normalized to the +same value by the programmer, e.g., {}\code{float(3)+4.5} rather than just +{}\code{3+4.5}. + +\index{complex number} +\item[complex number] + +An extension of the familiar real number system in which all numbers are +expressed as a sum of a real part and an imaginary part. Imaginary numbers +are real multiples of the imaginary unit (the square root of {}\code{-1}), +often written {}\code{i} in mathematics or {}\code{j} in engineering. +Python has builtin support for complex numbers, which are written with this +latter notation; the imaginary part is written with a {}\code{j} suffix, +e.g., {}\code{3+1j}. To get access to complex equivalents of the +{}\module{math} module, use {}\module{cmath}. Use of complex numbers is a +fairy advanced mathematical feature. If you're not aware of a need for it's +almost certain you can safely ignore them. \index{descriptor} \item[descriptor] @@ -99,14 +119,14 @@ _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192) \index{generator} \item[generator] -A function that returns an iterator. It looks like a normal function -except that the \keyword{yield} keyword is used instead of -{}\keyword{return}. Generator functions often contain one or more -{}\keyword{for} or \keyword{while} loops that \keyword{yield} elements -back to the caller. The function execution is stopped at the -{}\keyword{yield} keyword (returning the result) and is resumed there -when the next element is requested by calling the \method{next()} -method of the returned iterator. +A function that returns an iterator. It looks like a normal function except +that values are returned to the caller using a \keyword{yield} statement +instead of a {}\keyword{return} statement. Generator functions often +contain one or more {}\keyword{for} or \keyword{while} loops that +\keyword{yield} elements back to the caller. The function execution is +stopped at the {}\keyword{yield} keyword (returning the result) and is +resumed there when the next element is requested by calling the +\method{next()} method of the returned iterator. \index{GIL} \item[GIL] @@ -134,7 +154,7 @@ sophisticated, multi-platform GUI application. \index{immutable} \item[immutable] -A object with fixed value. Immutable objects are numbers, strings or +An object with fixed value. Immutable objects are numbers, strings or tuples (and more). Such an object cannot be altered. A new object has to be created if a different value has to be stored. They play an important role in places where a constant hash value is needed. For @@ -149,7 +169,7 @@ to the \code{2.75} returned by float division. Also called always be another integer (having the floor function applied to it). However, if one of the operands is another numeric type (such as a {}\class{float}), the result will be coerced (see \emph{coercion}) to -a common type. For example, a integer divided by a float will result +a common type. For example, an integer divided by a float will result in a float value, possibly with a decimal fraction. Integer division can be forced by using the \code{//} operator instead of the \code{/} operator. See also \emph{__future__}. @@ -164,11 +184,11 @@ packages (remember \code{help(x)}). \index{interpreted} \item[interpreted] -Python is an interpreted language, opposed to a compiled one. This -means that the source files can be run right away without first making -an executable which is then run. Interpreted languages typically have -a shorter development/debug cycle than compiled ones. See also -{}\emph{interactive}. +Python is an interpreted language, as opposed to a compiled one. This means +that the source files can be run directly without first creating an +executable which is then run. Interpreted languages typically have a +shorter development/debug cycle than compiled ones, though their programs +generally also run more slowly. See also {}\emph{interactive}. \index{iterable} \item[iterable] |