@@ -406,9 +406,9 @@ The extended form, ``assert expression1, expression2``, is equivalent to ::
406
406
407
407
These equivalences assume that :const: `__debug__ ` and :exc: `AssertionError ` refer to
408
408
the built-in variables with those names. In the current implementation, the
409
- built-in variable :const: ` __debug__ ` is ``True `` under normal circumstances,
409
+ built-in variable `` __debug__ ` ` is ``True `` under normal circumstances,
410
410
``False `` when optimization is requested (command line option :option: `-O `). The current
411
- code generator emits no code for an assert statement when optimization is
411
+ code generator emits no code for an :keyword: ` assert ` statement when optimization is
412
412
requested at compile time. Note that it is unnecessary to include the source
413
413
code for the expression that failed in the error message; it will be displayed
414
414
as part of the stack trace.
@@ -531,8 +531,8 @@ The :keyword:`!yield` statement
531
531
yield_stmt: `yield_expression `
532
532
533
533
A :keyword: `yield ` statement is semantically equivalent to a :ref: `yield
534
- expression <yieldexpr>`. The yield statement can be used to omit the parentheses
535
- that would otherwise be required in the equivalent yield expression
534
+ expression <yieldexpr>`. The `` yield `` statement can be used to omit the
535
+ parentheses that would otherwise be required in the equivalent yield expression
536
536
statement. For example, the yield statements ::
537
537
538
538
yield <expr>
@@ -544,7 +544,7 @@ are equivalent to the yield expression statements ::
544
544
(yield from <expr>)
545
545
546
546
Yield expressions and statements are only used when defining a :term: `generator `
547
- function, and are only used in the body of the generator function. Using yield
547
+ function, and are only used in the body of the generator function. Using :keyword: ` yield `
548
548
in a function definition is sufficient to cause that definition to create a
549
549
generator function instead of a normal function.
550
550
@@ -964,25 +964,14 @@ The :keyword:`!global` statement
964
964
.. productionlist :: python-grammar
965
965
global_stmt: "global" `identifier ` ("," `identifier `)*
966
966
967
- The :keyword: `global ` statement is a declaration which holds for the entire
968
- current code block. It means that the listed identifiers are to be interpreted
969
- as globals. It would be impossible to assign to a global variable without
967
+ The :keyword: `global ` statement causes the listed identifiers to be interpreted
968
+ as globals. It would be impossible to assign to a global variable without
970
969
:keyword: `!global `, although free variables may refer to globals without being
971
970
declared global.
972
971
973
- Names listed in a :keyword: `global ` statement must not be used in the same code
974
- block textually preceding that :keyword: `!global ` statement.
975
-
976
- Names listed in a :keyword: `global ` statement must not be defined as formal
977
- parameters, or as targets in :keyword: `with ` statements or :keyword: `except ` clauses, or in a :keyword: `for ` target list, :keyword: `class `
978
- definition, function definition, :keyword: `import ` statement, or variable
979
- annotation.
980
-
981
- .. impl-detail ::
982
-
983
- The current implementation does not enforce some of these restrictions, but
984
- programs should not abuse this freedom, as future implementations may enforce
985
- them or silently change the meaning of the program.
972
+ The :keyword: `global ` statement applies to the entire scope of a function or
973
+ class body. A :exc: `SyntaxError ` is raised if a variable is used or
974
+ assigned to prior to its global declaration in the scope.
986
975
987
976
.. index ::
988
977
pair: built-in function; exec
@@ -1018,7 +1007,7 @@ identifiers. If a name is bound in more than one nonlocal scope, the
1018
1007
nearest binding is used. If a name is not bound in any nonlocal scope,
1019
1008
or if there is no nonlocal scope, a :exc: `SyntaxError ` is raised.
1020
1009
1021
- The nonlocal statement applies to the entire scope of a function or
1010
+ The :keyword: ` nonlocal ` statement applies to the entire scope of a function or
1022
1011
class body. A :exc: `SyntaxError ` is raised if a variable is used or
1023
1012
assigned to prior to its nonlocal declaration in the scope.
1024
1013
0 commit comments