@@ -29,7 +29,7 @@ Arithmetic conversions
2929
3030When a description of an arithmetic operator below uses the phrase "the numeric
3131arguments are converted to a common type," this means that the operator
32- implementation for built-in types works that way :
32+ implementation for built-in types works as follows :
3333
3434* If either argument is a complex number, the other is converted to complex;
3535
@@ -38,8 +38,9 @@ implementation for built-in types works that way:
3838
3939* otherwise, both must be integers and no conversion is necessary.
4040
41- Some additional rules apply for certain operators (e.g., a string left argument
42- to the '%' operator). Extensions must define their own conversion behavior.
41+ Some additional rules apply for certain operators (e.g., a string as a left
42+ argument to the '%' operator). Extensions must define their own conversion
43+ behavior.
4344
4445
4546.. _atoms :
@@ -183,7 +184,7 @@ nesting from left to right, and evaluating the expression to produce an element
183184each time the innermost block is reached.
184185
185186Note that the comprehension is executed in a separate scope, so names assigned
186- to in the target list don't "leak" in the enclosing scope.
187+ to in the target list don't "leak" into the enclosing scope.
187188
188189
189190.. _lists :
@@ -293,7 +294,7 @@ for comprehensions, except that it is enclosed in parentheses instead of
293294brackets or curly braces.
294295
295296Variables used in the generator expression are evaluated lazily when the
296- :meth: `~generator.__next__ ` method is called for generator object (in the same
297+ :meth: `~generator.__next__ ` method is called for the generator object (in the same
297298fashion as normal generators). However, the leftmost :keyword: `for ` clause is
298299immediately evaluated, so that an error produced by it can be seen before any
299300other possible error in the code that handles the generator expression.
@@ -302,7 +303,7 @@ may depend on the previous :keyword:`for` loop. For example: ``(x*y for x in
302303range(10) for y in bar(x)) ``.
303304
304305The parentheses can be omitted on calls with only one argument. See section
305- :ref: `calls ` for the detail .
306+ :ref: `calls ` for details .
306307
307308
308309.. _yieldexpr :
@@ -327,12 +328,12 @@ When a generator function is called, it returns an iterator known as a
327328generator. That generator then controls the execution of a generator function.
328329The execution starts when one of the generator's methods is called. At that
329330time, the execution proceeds to the first yield expression, where it is
330- suspended again, returning the value of :token: `expression_list ` to generator's
331+ suspended again, returning the value of :token: `expression_list ` to the generator's
331332caller. By suspended, we mean that all local state is retained, including the
332333current bindings of local variables, the instruction pointer, and the internal
333334evaluation stack. When the execution is resumed by calling one of the
334335generator's methods, the function can proceed exactly as if the yield expression
335- was just another external call. The value of the yield expression after
336+ were just another external call. The value of the yield expression after
336337resuming depends on the method which resumed the execution. If
337338:meth: `~generator.__next__ ` is used (typically via either a :keyword: `for ` or
338339the :func: `next ` builtin) then the result is :const: `None `. Otherwise, if
@@ -344,10 +345,10 @@ that method.
344345All of this makes generator functions quite similar to coroutines; they yield
345346multiple times, they have more than one entry point and their execution can be
346347suspended. The only difference is that a generator function cannot control
347- where should the execution continue after it yields; the control is always
348+ where the execution should continue after it yields; the control is always
348349transferred to the generator's caller.
349350
350- yield expressions are allowed in the :keyword: `try ` clause of a :keyword: `try `
351+ Yield expressions are allowed in the :keyword: `try ` clause of a :keyword: `try `
351352... :keyword: `finally ` construct. If the generator is not resumed before it is
352353finalized (by reaching a zero reference count or by being garbage collected),
353354the generator-iterator's :meth: `~generator.close ` method will be called,
@@ -430,7 +431,7 @@ is already executing raises a :exc:`ValueError` exception.
430431
431432.. method :: generator.throw(type[, value[, traceback]])
432433
433- Raises an exception of type ``type `` at the point where generator was paused,
434+ Raises an exception of type ``type `` at the point where the generator was paused,
434435 and returns the next value yielded by the generator function. If the generator
435436 exits without yielding another value, a :exc: `StopIteration ` exception is
436437 raised. If the generator function does not catch the passed-in exception, or
@@ -520,11 +521,11 @@ An attribute reference is a primary followed by a period and a name:
520521
521522The primary must evaluate to an object of a type that supports attribute
522523references, which most objects do. This object is then asked to produce the
523- attribute whose name is the identifier (which can be customized by overriding
524- the :meth: `__getattr__ ` method). If this attribute is not available, the
525- exception :exc: `AttributeError ` is raised. Otherwise, the type and value of the
526- object produced is determined by the object. Multiple evaluations of the same
527- attribute reference may yield different objects.
524+ attribute whose name is the identifier. This production can be customized by
525+ overriding the :meth: `__getattr__ ` method). If this attribute is not available,
526+ the exception :exc: `AttributeError ` is raised. Otherwise, the type and value of
527+ the object produced is determined by the object. Multiple evaluations of the
528+ same attribute reference may yield different objects.
528529
529530
530531.. _subscriptions :
@@ -549,9 +550,9 @@ A subscription selects an item of a sequence (string, tuple or list) or mapping
549550.. productionlist ::
550551 subscription: `primary ` "[" `expression_list ` "]"
551552
552- The primary must evaluate to an object that supports subscription, e.g. a list
553- or dictionary . User-defined objects can support subscription by defining a
554- :meth: `__getitem__ ` method.
553+ The primary must evaluate to an object that supports subscription (lists or
554+ dictionaries for example) . User-defined objects can support subscription by
555+ defining a :meth: `__getitem__ ` method.
555556
556557For built-in objects, there are two types of objects that support subscription:
557558
@@ -660,8 +661,8 @@ series of :term:`arguments <argument>`:
660661 keyword_arguments: `keyword_item ` ("," `keyword_item `)*
661662 keyword_item: `identifier ` "=" `expression `
662663
663- A trailing comma may be present after the positional and keyword arguments but
664- does not affect the semantics.
664+ An optional trailing comma may be present after the positional and keyword arguments
665+ but does not affect the semantics.
665666
666667.. index ::
667668 single: parameter; call semantics
@@ -951,9 +952,9 @@ point number using the :func:`abs` function if appropriate.
951952.. index :: single: addition
952953
953954The ``+ `` (addition) operator yields the sum of its arguments. The arguments
954- must either both be numbers or both sequences of the same type. In the former
955- case, the numbers are converted to a common type and then added together. In
956- the latter case, the sequences are concatenated.
955+ must either both be numbers or both be sequences of the same type. In the
956+ former case, the numbers are converted to a common type and then added together.
957+ In the latter case, the sequences are concatenated.
957958
958959.. index :: single: subtraction
959960
@@ -1114,7 +1115,7 @@ Comparison of objects of the same type depends on the type:
11141115 another one is made arbitrarily but consistently within one execution of a
11151116 program.
11161117
1117- Comparison of objects of the differing types depends on whether either of the
1118+ Comparison of objects of differing types depends on whether either of the
11181119types provide explicit support for the comparison. Most numeric types can be
11191120compared with one another. When cross-type comparison is not supported, the
11201121comparison method returns ``NotImplemented ``.
@@ -1124,7 +1125,7 @@ comparison method returns ``NotImplemented``.
11241125The operators :keyword: `in ` and :keyword: `not in ` test for membership. ``x in
11251126s `` evaluates to true if *x * is a member of *s *, and false otherwise. ``x not
11261127in s `` returns the negation of ``x in s ``. All built-in sequences and set types
1127- support this as well as dictionary, for which :keyword: `in ` tests whether a the
1128+ support this as well as dictionary, for which :keyword: `in ` tests whether the
11281129dictionary has a given key. For container types such as list, tuple, set,
11291130frozenset, dict, or collections.deque, the expression ``x in y `` is equivalent
11301131to ``any(x is e or x == e for e in y) ``.
@@ -1210,9 +1211,9 @@ returned; otherwise, *y* is evaluated and the resulting value is returned.
12101211they return to ``False `` and ``True ``, but rather return the last evaluated
12111212argument. This is sometimes useful, e.g., if ``s `` is a string that should be
12121213replaced by a default value if it is empty, the expression ``s or 'foo' `` yields
1213- the desired value. Because :keyword: `not ` has to invent a value anyway , it does
1214- not bother to return a value of the same type as its argument, so e.g., `` not
1215- 'foo' `` yields ``False ``, not ``'' ``.)
1214+ the desired value. Because :keyword: `not ` has to create a new value , it
1215+ returns a boolean value regardless of the type of its argument
1216+ (for example, `` not 'foo' `` produces ``False `` rather than ``'' ``.)
12161217
12171218
12181219Conditional expressions
@@ -1230,8 +1231,8 @@ Conditional expressions
12301231Conditional expressions (sometimes called a "ternary operator") have the lowest
12311232priority of all Python operations.
12321233
1233- The expression ``x if C else y `` first evaluates the condition, *C * (* not * *x *);
1234- if *C * is true, *x * is evaluated and its value is returned; otherwise, *y * is
1234+ The expression ``x if C else y `` first evaluates the condition, *C * rather than *x *.
1235+ If *C * is true, *x * is evaluated and its value is returned; otherwise, *y * is
12351236evaluated and its value is returned.
12361237
12371238See :pep: `308 ` for more details about conditional expressions.
@@ -1252,10 +1253,9 @@ Lambdas
12521253 lambda_expr: "lambda" [`parameter_list `]: `expression `
12531254 lambda_expr_nocond: "lambda" [`parameter_list `]: `expression_nocond `
12541255
1255- Lambda expressions (sometimes called lambda forms) have the same syntactic position as
1256- expressions. They are a shorthand to create anonymous functions; the expression
1257- ``lambda arguments: expression `` yields a function object. The unnamed object
1258- behaves like a function object defined with ::
1256+ Lambda expressions (sometimes called lambda forms) are create anonymous
1257+ functions. The expression ``lambda arguments: expression `` yields a function
1258+ object. The unnamed object behaves like a function object defined with ::
12591259
12601260 def <lambda>(arguments):
12611261 return expression
@@ -1318,13 +1318,15 @@ Operator precedence
13181318
13191319.. index :: pair: operator; precedence
13201320
1321- The following table summarizes the operator precedences in Python, from lowest
1321+ The following table summarizes the operator precedence in Python, from lowest
13221322precedence (least binding) to highest precedence (most binding). Operators in
13231323the same box have the same precedence. Unless the syntax is explicitly given,
13241324operators are binary. Operators in the same box group left to right (except for
1325- comparisons, including tests, which all have the same precedence and chain from
1326- left to right --- see section :ref: `comparisons ` --- and exponentiation, which
1327- groups from right to left).
1325+ exponentiation, which groups from right to left).
1326+
1327+ Note that comparisons, membership tests, and identity tests, all have the same
1328+ precedence and have a left-to-right chaining feature as described in the
1329+ :ref: `comparisons ` section.
13281330
13291331
13301332+-----------------------------------------------+-------------------------------------+
0 commit comments