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

Skip to content

Commit ed51494

Browse files
committed
Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
translation more difficult, as well as reading the English more difficult for non-native speakers.
1 parent beb6713 commit ed51494

1 file changed

Lines changed: 62 additions & 58 deletions

File tree

Doc/tut/tut.tex

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ \subsection{Interactive Mode \label{interactive}}
242242
(\samp{>\code{>}>~}); for continuation lines it prompts with the
243243
\emph{secondary prompt}, by default three dots (\samp{...~}).
244244
The interpreter prints a welcome message stating its version number
245-
and a copyright notice before printing the first prompt, e.g.:
245+
and a copyright notice before printing the first prompt:
246246

247247
\begin{verbatim}
248248
python
@@ -325,8 +325,8 @@ \subsection{The Interactive Startup File \label{startup}}
325325
this file.
326326

327327
If you want to read an additional start-up file from the current
328-
directory, you can program this in the global start-up file,
329-
e.g.\ \samp{if os.path.isfile('.pythonrc.py'):
328+
directory, you can program this in the global start-up file using code
329+
like \samp{if os.path.isfile('.pythonrc.py'):
330330
execfile('.pythonrc.py')}. If you want to use the startup file in a
331331
script, you must do this explicitly in the script:
332332

@@ -527,7 +527,7 @@ \subsection{Strings \label{strings}}
527527
\end{verbatim}
528528

529529
String literals can span multiple lines in several ways. Newlines can
530-
be escaped with backslashes, e.g.:
530+
be escaped with backslashes:
531531

532532
\begin{verbatim}
533533
hello = "This is a rather long string containing\n\
@@ -728,7 +728,7 @@ \subsection{Strings \label{strings}}
728728
the edges labeled \var{i} and \var{j}, respectively.
729729

730730
For non-negative indices, the length of a slice is the difference of
731-
the indices, if both are within bounds, e.g., the length of
731+
the indices, if both are within bounds. For example, the length of
732732
\code{word[1:3]} is 2.
733733

734734
The built-in function \function{len()} returns the length of a string:
@@ -799,8 +799,8 @@ \subsection{Unicode Strings \label{unicodeStrings}}
799799
u'Hello\\\\u0020World !'
800800
\end{verbatim}
801801

802-
The raw mode is most useful when you have to enter lots of backslashes
803-
e.g. in regular expressions.
802+
The raw mode is most useful when you have to enter lots of
803+
backslashes, as can be necessary in regular expressions.
804804

805805
Apart from these standard encodings, Python provides a whole set of
806806
other ways of creating Unicode strings on the basis of a known
@@ -1073,7 +1073,7 @@ \section{\keyword{for} Statements \label{for}}
10731073
or giving the user the ability to define both the iteration step and
10741074
halting condition (as C), Python's
10751075
\keyword{for}\stindex{for} statement iterates over the items of any
1076-
sequence (e.g., a list or a string), in the order that they appear in
1076+
sequence (a list or a string), in the order that they appear in
10771077
the sequence. For example (no pun intended):
10781078
% One suggestion was to give a real C example here, but that may only
10791079
% serve to confuse non-C programmers.
@@ -1090,10 +1090,10 @@ \section{\keyword{for} Statements \label{for}}
10901090
\end{verbatim}
10911091

10921092
It is not safe to modify the sequence being iterated over in the loop
1093-
(this can only happen for mutable sequence types, i.e., lists). If
1094-
you need to modify the list you are iterating over, e.g., duplicate
1095-
selected items, you must iterate over a copy. The slice notation
1096-
makes this particularly convenient:
1093+
(this can only happen for mutable sequence types, such as lists). If
1094+
you need to modify the list you are iterating over (for example, to
1095+
duplicate selected items) you must iterate over a copy. The slice
1096+
notation makes this particularly convenient:
10971097

10981098
\begin{verbatim}
10991099
>>> for x in a[:]: # make a slice copy of the entire list
@@ -1108,7 +1108,7 @@ \section{The \function{range()} Function \label{range}}
11081108

11091109
If you do need to iterate over a sequence of numbers, the built-in
11101110
function \function{range()} comes in handy. It generates lists
1111-
containing arithmetic progressions, e.g.:
1111+
containing arithmetic progressions:
11121112

11131113
\begin{verbatim}
11141114
>>> range(10)
@@ -1245,7 +1245,7 @@ \section{Defining Functions \label{functions}}
12451245
the object).\footnote{
12461246
Actually, \emph{call by object reference} would be a better
12471247
description, since if a mutable object is passed, the caller
1248-
will see any changes the callee makes to it (e.g., items
1248+
will see any changes the callee makes to it (items
12491249
inserted into a list).
12501250
} When a function calls another function, a new local symbol table is
12511251
created for that call.
@@ -1331,7 +1331,7 @@ \subsection{Default Argument Values \label{defaultArgs}}
13311331

13321332
The most useful form is to specify a default value for one or more
13331333
arguments. This creates a function that can be called with fewer
1334-
arguments than it is defined, e.g.
1334+
arguments than it is defined
13351335

13361336
\begin{verbatim}
13371337
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
@@ -1349,7 +1349,7 @@ \subsection{Default Argument Values \label{defaultArgs}}
13491349
\code{ask_ok('OK to overwrite the file?', 2)}.
13501350

13511351
The default values are evaluated at the point of function definition
1352-
in the \emph{defining} scope, so that e.g.
1352+
in the \emph{defining} scope, so that
13531353

13541354
\begin{verbatim}
13551355
i = 5
@@ -1509,7 +1509,7 @@ \subsection{Lambda Forms \label{lambda}}
15091509
expression. Semantically, they are just syntactic sugar for a normal
15101510
function definition. Like nested function definitions, lambda forms
15111511
cannot reference variables from the containing scope, but this can be
1512-
overcome through the judicious use of default argument values, e.g.
1512+
overcome through the judicious use of default argument values:
15131513

15141514
\begin{verbatim}
15151515
>>> def make_incrementor(n):
@@ -1853,7 +1853,7 @@ \section{The \keyword{del} statement \label{del}}
18531853

18541854
\section{Tuples and Sequences \label{tuples}}
18551855

1856-
We saw that lists and strings have many common properties, e.g.,
1856+
We saw that lists and strings have many common properties, such as
18571857
indexing and slicing operations. They are two examples of
18581858
\emph{sequence} data types. Since Python is an evolving language,
18591859
other sequence data types may be added. There is also another
@@ -1879,9 +1879,9 @@ \section{Tuples and Sequences \label{tuples}}
18791879
or without surrounding parentheses, although often parentheses are
18801880
necessary anyway (if the tuple is part of a larger expression).
18811881

1882-
Tuples have many uses, e.g., (x, y) coordinate pairs, employee records
1883-
from a database, etc. Tuples, like strings, are immutable: it is not
1884-
possible to assign to the individual items of a tuple (you can
1882+
Tuples have many uses. For example: (x, y) coordinate pairs, employee
1883+
records from a database, etc. Tuples, like strings, are immutable: it
1884+
is not possible to assign to the individual items of a tuple (you can
18851885
simulate much of the same effect with slicing and concatenation,
18861886
though). It is also possible to create tuples which contain mutable
18871887
objects, such as lists.
@@ -1907,7 +1907,7 @@ \section{Tuples and Sequences \label{tuples}}
19071907
The statement \code{t = 12345, 54321, 'hello!'} is an example of
19081908
\emph{tuple packing}: the values \code{12345}, \code{54321} and
19091909
\code{'hello!'} are packed together in a tuple. The reverse operation
1910-
is also possible, e.g.:
1910+
is also possible:
19111911

19121912
\begin{verbatim}
19131913
>>> x, y, z = t
@@ -1992,8 +1992,9 @@ \section{More on Conditions \label{conditions}}
19921992
have the same priority, which is lower than that of all numerical
19931993
operators.
19941994

1995-
Comparisons can be chained: e.g., \code{a < b == c} tests whether
1996-
\code{a} is less than \code{b} and moreover \code{b} equals \code{c}.
1995+
Comparisons can be chained. For example, \code{a < b == c} tests
1996+
whether \code{a} is less than \code{b} and moreover \code{b} equals
1997+
\code{c}.
19971998

19981999
Comparisons may be combined by the Boolean operators \code{and} and
19992000
\code{or}, and the outcome of a comparison (or of any other Boolean
@@ -2198,7 +2199,7 @@ \subsection{The Module Search Path \label{searchPath}}
21982199
for a file named \file{spam.py} in the current directory,
21992200
and then in the list of directories specified by
22002201
the environment variable \envvar{PYTHONPATH}. This has the same syntax as
2201-
the shell variable \envvar{PATH}, i.e., a list of
2202+
the shell variable \envvar{PATH}, that is, a list of
22022203
directory names. When \envvar{PYTHONPATH} is not set, or when the file
22032204
is not found there, the search continues in an installation-dependent
22042205
default path; on \UNIX{}, this is usually \file{.:/usr/local/lib/python}.
@@ -2289,7 +2290,8 @@ \section{Standard Modules \label{standardModules}}
22892290
interpreter; these provide access to operations that are not part of
22902291
the core of the language but are nevertheless built in, either for
22912292
efficiency or to provide access to operating system primitives such as
2292-
system calls. The set of such modules is a configuration option; e.g.,
2293+
system calls. The set of such modules is a configuration option which
2294+
also dependson the underlying platform For example,
22932295
the \module{amoeba} module is only provided on systems that somehow
22942296
support Amoeba primitives. One particular module deserves some
22952297
attention: \module{sys}\refstmodindex{sys}, which is built into every
@@ -2316,7 +2318,7 @@ \section{Standard Modules \label{standardModules}}
23162318
interpreter's search path for modules. It is initialized to a default
23172319
path taken from the environment variable \envvar{PYTHONPATH}, or from
23182320
a built-in default if \envvar{PYTHONPATH} is not set. You can modify
2319-
it using standard list operations, e.g.:
2321+
it using standard list operations:
23202322

23212323
\begin{verbatim}
23222324
>>> import sys
@@ -2384,15 +2386,15 @@ \section{Packages \label{packages}}
23842386
Suppose you want to design a collection of modules (a ``package'') for
23852387
the uniform handling of sound files and sound data. There are many
23862388
different sound file formats (usually recognized by their extension,
2387-
e.g. \file{.wav}, \file{.aiff}, \file{.au}), so you may need to create
2388-
and maintain a growing collection of modules for the conversion
2389-
between the various file formats. There are also many different
2390-
operations you might want to perform on sound data (e.g. mixing,
2391-
adding echo, applying an equalizer function, creating an artificial
2392-
stereo effect), so in addition you will be writing a never-ending
2393-
stream of modules to perform these operations. Here's a possible
2394-
structure for your package (expressed in terms of a hierarchical
2395-
filesystem):
2389+
for example: \file{.wav}, \file{.aiff}, \file{.au}), so you may need
2390+
to create and maintain a growing collection of modules for the
2391+
conversion between the various file formats. There are also many
2392+
different operations you might want to perform on sound data (such as
2393+
mixing, adding echo, applying an equalizer function, creating an
2394+
artificial stereo effect), so in addition you will be writing a
2395+
never-ending stream of modules to perform these operations. Here's a
2396+
possible structure for your package (expressed in terms of a
2397+
hierarchical filesystem):
23962398

23972399
\begin{verbatim}
23982400
Sound/ Top-level package
@@ -2436,7 +2438,7 @@ \section{Packages \label{packages}}
24362438
\end{verbatim}
24372439

24382440
This loads the submodule \module{Sound.Effects.echo}. It must be referenced
2439-
with its full name, e.g.
2441+
with its full name.
24402442

24412443
\begin{verbatim}
24422444
Sound.Effects.echo.echofilter(input, output, delay=0.7, atten=4)
@@ -2523,7 +2525,7 @@ \subsection{Importing * From a Package \label{pkg-import-star}}
25232525
defined in the package. This includes any names defined (and
25242526
submodules explicitly loaded) by \file{__init__.py}. It also includes any
25252527
submodules of the package that were explicitly loaded by previous
2526-
import statements, e.g.
2528+
import statements. Consider this code:
25272529

25282530
\begin{verbatim}
25292531
import Sound.Effects.echo
@@ -2703,8 +2705,8 @@ \section{Fancier Output Formatting \label{formatting}}
27032705
The value of PI is approximately 3.142.
27042706
\end{verbatim}
27052707
2706-
If there is more than one format in the string you pass a tuple as
2707-
right operand, e.g.
2708+
If there is more than one format in the string, you need to pass a
2709+
tuple as right operand, as in this example:
27082710
27092711
\begin{verbatim}
27102712
>>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}
@@ -2727,7 +2729,7 @@ \section{Fancier Output Formatting \label{formatting}}
27272729
If you have a really long format string that you don't want to split
27282730
up, it would be nice if you could reference the variables to be
27292731
formatted by name instead of by position. This can be done by using
2730-
an extension of C formats using the form \code{\%(name)format}, e.g.
2732+
form \code{\%(name)format}, as shown here:
27312733
27322734
\begin{verbatim}
27332735
>>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
@@ -3042,8 +3044,8 @@ \section{Handling Exceptions \label{handling}}
30423044
specify handlers for different exceptions. At most one handler will
30433045
be executed. Handlers only handle exceptions that occur in the
30443046
corresponding try clause, not in other handlers of the same
3045-
\keyword{try} statement. An except clause may name multiple exceptions
3046-
as a parenthesized list, e.g.:
3047+
\keyword{try} statement. An except clause may name multiple exceptions
3048+
as a parenthesized list, for example:
30473049
30483050
\begin{verbatim}
30493051
... except (RuntimeError, TypeError, NameError):
@@ -3310,8 +3312,9 @@ \section{Python Scopes and Name Spaces \label{scopes}}
33103312
Attributes may be read-only or writable. In the latter case,
33113313
assignment to attributes is possible. Module attributes are writable:
33123314
you can write \samp{modname.the_answer = 42}. Writable attributes may
3313-
also be deleted with the \keyword{del} statement, e.g.
3314-
\samp{del modname.the_answer}.
3315+
also be deleted with the \keyword{del} statement. For example,
3316+
\samp{del modname.the_answer} will remove the attribute
3317+
\member{the_answer} from the object named by \code{modname}.
33153318
33163319
Name spaces are created at different moments and have different
33173320
lifetimes. The namespace containing the built-in names is created
@@ -3338,7 +3341,7 @@ \section{Python Scopes and Name Spaces \label{scopes}}
33383341
33393342
Although scopes are determined statically, they are used dynamically.
33403343
At any time during execution, exactly three nested scopes are in use
3341-
(i.e., exactly three namespaces are directly accessible): the
3344+
(exactly three namespaces are directly accessible): the
33423345
innermost scope, which is searched first, contains the local names,
33433346
the middle scope, searched next, contains the current module's global
33443347
names, and the outermost scope (searched last) is the namespace
@@ -3512,7 +3515,7 @@ \subsection{Instance Objects \label{instanceObjects}}
35123515
The second kind of attribute references understood by instance objects
35133516
are \emph{methods}. A method is a function that ``belongs to'' an
35143517
object. (In Python, the term method is not unique to class instances:
3515-
other object types can have methods as well, e.g., list objects have
3518+
other object types can have methods as well. For example, list objects have
35163519
methods called append, insert, remove, sort, and so on. However,
35173520
below, we'll use the term method exclusively to mean methods of class
35183521
instance objects, unless explicitly stated otherwise.)
@@ -3529,7 +3532,7 @@ \subsection{Instance Objects \label{instanceObjects}}
35293532
35303533
\subsection{Method Objects \label{methodObjects}}
35313534
3532-
Usually, a method is called immediately, e.g.:
3535+
Usually, a method is called immediately:
35333536
35343537
\begin{verbatim}
35353538
x.f()
@@ -3583,9 +3586,10 @@ \section{Random Remarks \label{remarks}}
35833586
Data attributes override method attributes with the same name; to
35843587
avoid accidental name conflicts, which may cause hard-to-find bugs in
35853588
large programs, it is wise to use some kind of convention that
3586-
minimizes the chance of conflicts, e.g., capitalize method names,
3587-
prefix data attribute names with a small unique string (perhaps just
3588-
an underscore), or use verbs for methods and nouns for data attributes.
3589+
minimizes the chance of conflicts. Possible conventions include
3590+
capitalizing method names, prefixing data attribute names with a small
3591+
unique string (perhaps just an underscore), or using verbs for methods
3592+
and nouns for data attributes.
35893593
35903594
35913595
Data attributes may be referenced by methods as well as by ordinary
@@ -3647,7 +3651,7 @@ \section{Random Remarks \label{remarks}}
36473651
36483652
36493653
Methods may call other methods by using method attributes of the
3650-
\code{self} argument, e.g.:
3654+
\code{self} argument:
36513655
36523656
\begin{verbatim}
36533657
class Bag:
@@ -3690,7 +3694,7 @@ \section{Inheritance \label{inheritance}}
36903694
The name \class{BaseClassName} must be defined in a scope containing
36913695
the derived class definition. Instead of a base class name, an
36923696
expression is also allowed. This is useful when the base class is
3693-
defined in another module, e.g.,
3697+
defined in another module,
36943698
36953699
\begin{verbatim}
36963700
class DerivedClassName(modname.BaseClassName):
@@ -3785,10 +3789,10 @@ \section{Private Variables \label{private}}
37853789
instance variables by code outside the class. Note that the mangling
37863790
rules are designed mostly to avoid accidents; it still is possible for
37873791
a determined soul to access or modify a variable that is considered
3788-
private. This can even be useful, e.g. for the debugger, and that's
3789-
one reason why this loophole is not closed. (Buglet: derivation of a
3790-
class with the same name as the base class makes use of private
3791-
variables of the base class possible.)
3792+
private. This can even be useful in special circumstances, such as in
3793+
the debugger, and that's one reason why this loophole is not closed.
3794+
(Buglet: derivation of a class with the same name as the base class
3795+
makes use of private variables of the base class possible.)
37923796
37933797
Notice that code passed to \code{exec}, \code{eval()} or
37943798
\code{evalfile()} does not consider the classname of the invoking
@@ -3824,7 +3828,7 @@ \section{Odds and Ends \label{odds}}
38243828
38253829
Sometimes it is useful to have a data type similar to the Pascal
38263830
``record'' or C ``struct'', bundling together a couple of named data
3827-
items. An empty class definition will do nicely, e.g.:
3831+
items. An empty class definition will do nicely:
38283832
38293833
\begin{verbatim}
38303834
class Employee:

0 commit comments

Comments
 (0)