Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dbb4078

Browse files
author
Skip Montanaro
committed
- add entry for complex number
- fix a couple typos - refine definitions for "interpreted" and "coercion" based upon updates on the python glossary wiki
1 parent d732c95 commit dbb4078

1 file changed

Lines changed: 42 additions & 22 deletions

File tree

Doc/tut/glossary.tex

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,33 @@ \chapter{Glossary\label{glossary}}
3737

3838
\index{coercion}
3939
\item[coercion]
40-
Converting data from one type to another. For example,
41-
{}\code{int(3.15)} coerces the floating point number to the integer,
42-
{}\code{3}. Most mathematical operations have rules for coercing
43-
their arguments to a common type. For instance, adding \code{3+4.5},
44-
causes the integer \code{3} to be coerced to be a float
45-
{}\code{3.0} before adding to \code{4.5} resulting in the float
46-
{}\code{7.5}.
40+
41+
The implicit conversion of an instance of one type to another during an
42+
operation which involves two arguments of the same type. For example,
43+
{}\code{int(3.15)} converts the floating point number to the integer,
44+
{}\code{3}, but in {}\code{3+4.5}, each argument is of a different type (one
45+
int, one float), and both must be converted to the same type before they can
46+
be added or it will raise a {}\code{TypeError}. Coercion between two
47+
operands can be performed with the {}\code{coerce} builtin function; thus,
48+
{}\code{3+4.5} is equivalent to calling {}\code{operator.add(*coerce(3,
49+
4.5))} and results in {}\code{operator.add(3.0, 4.5)}. Without coercion,
50+
all arguments of even compatible types would have to be normalized to the
51+
same value by the programmer, e.g., {}\code{float(3)+4.5} rather than just
52+
{}\code{3+4.5}.
53+
54+
\index{complex number}
55+
\item[complex number]
56+
57+
An extension of the familiar real number system in which all numbers are
58+
expressed as a sum of a real part and an imaginary part. Imaginary numbers
59+
are real multiples of the imaginary unit (the square root of {}\code{-1}),
60+
often written {}\code{i} in mathematics or {}\code{j} in engineering.
61+
Python has builtin support for complex numbers, which are written with this
62+
latter notation; the imaginary part is written with a {}\code{j} suffix,
63+
e.g., {}\code{3+1j}. To get access to complex equivalents of the
64+
{}\module{math} module, use {}\module{cmath}. Use of complex numbers is a
65+
fairy advanced mathematical feature. If you're not aware of a need for it's
66+
almost certain you can safely ignore them.
4767

4868
\index{descriptor}
4969
\item[descriptor]
@@ -99,14 +119,14 @@ \chapter{Glossary\label{glossary}}
99119

100120
\index{generator}
101121
\item[generator]
102-
A function that returns an iterator. It looks like a normal function
103-
except that the \keyword{yield} keyword is used instead of
104-
{}\keyword{return}. Generator functions often contain one or more
105-
{}\keyword{for} or \keyword{while} loops that \keyword{yield} elements
106-
back to the caller. The function execution is stopped at the
107-
{}\keyword{yield} keyword (returning the result) and is resumed there
108-
when the next element is requested by calling the \method{next()}
109-
method of the returned iterator.
122+
A function that returns an iterator. It looks like a normal function except
123+
that values are returned to the caller using a \keyword{yield} statement
124+
instead of a {}\keyword{return} statement. Generator functions often
125+
contain one or more {}\keyword{for} or \keyword{while} loops that
126+
\keyword{yield} elements back to the caller. The function execution is
127+
stopped at the {}\keyword{yield} keyword (returning the result) and is
128+
resumed there when the next element is requested by calling the
129+
\method{next()} method of the returned iterator.
110130

111131
\index{GIL}
112132
\item[GIL]
@@ -134,7 +154,7 @@ \chapter{Glossary\label{glossary}}
134154

135155
\index{immutable}
136156
\item[immutable]
137-
A object with fixed value. Immutable objects are numbers, strings or
157+
An object with fixed value. Immutable objects are numbers, strings or
138158
tuples (and more). Such an object cannot be altered. A new object
139159
has to be created if a different value has to be stored. They play an
140160
important role in places where a constant hash value is needed. For
@@ -149,7 +169,7 @@ \chapter{Glossary\label{glossary}}
149169
always be another integer (having the floor function applied to it).
150170
However, if one of the operands is another numeric type (such as a
151171
{}\class{float}), the result will be coerced (see \emph{coercion}) to
152-
a common type. For example, a integer divided by a float will result
172+
a common type. For example, an integer divided by a float will result
153173
in a float value, possibly with a decimal fraction. Integer division
154174
can be forced by using the \code{//} operator instead of the \code{/}
155175
operator. See also \emph{__future__}.
@@ -164,11 +184,11 @@ \chapter{Glossary\label{glossary}}
164184

165185
\index{interpreted}
166186
\item[interpreted]
167-
Python is an interpreted language, opposed to a compiled one. This
168-
means that the source files can be run right away without first making
169-
an executable which is then run. Interpreted languages typically have
170-
a shorter development/debug cycle than compiled ones. See also
171-
{}\emph{interactive}.
187+
Python is an interpreted language, as opposed to a compiled one. This means
188+
that the source files can be run directly without first creating an
189+
executable which is then run. Interpreted languages typically have a
190+
shorter development/debug cycle than compiled ones, though their programs
191+
generally also run more slowly. See also {}\emph{interactive}.
172192

173193
\index{iterable}
174194
\item[iterable]

0 commit comments

Comments
 (0)