More updates to the annotated assignments docs (GH-13794)

This commit is contained in:
Ivan Levkivskyi 2019-06-04 11:37:46 +01:00 committed by GitHub
parent 4cdbc452ce
commit 8bcf2629a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -330,10 +330,9 @@ statement, of a variable or attribute annotation and an optional assignment stat
.. productionlist:: .. productionlist::
annotated_assignment_stmt: `augtarget` ":" `expression` annotated_assignment_stmt: `augtarget` ":" `expression`
: ["=" (`expression_list` | `yield_expression`)] : ["=" (`starred_expression` | `yield_expression`)]
The difference from normal :ref:`assignment` is that only single target and The difference from normal :ref:`assignment` is that only single target is allowed.
only single right hand side value is allowed.
For simple names as assignment targets, if in class or module scope, For simple names as assignment targets, if in class or module scope,
the annotations are evaluated and stored in a special class or module the annotations are evaluated and stored in a special class or module
@ -369,7 +368,7 @@ target, then the interpreter evaluates the target except for the last
.. versionchanged:: 3.8 .. versionchanged:: 3.8
Now annotated assignments allow same expressions in the right hand side as Now annotated assignments allow same expressions in the right hand side as
the augmented assignments. Previously, some expressions (like un-parenthesized the regular assignments. Previously, some expressions (like un-parenthesized
tuple expressions) caused a syntax error. tuple expressions) caused a syntax error.