[issue34939] Possibly spurious SyntaxError: annotated name can't be global
Rohan Padhye
report at bugs.python.org
Tue Oct 9 12:07:14 EDT 2018
Rohan Padhye <rohanpadhye at cs.berkeley.edu> added the comment:
Another point I'd like to make is that there is no error in either file or interactive if the annotated assignment appears before the `global` declaration like so:
```
x:int = 0
def set_x():
global x
x = 1
# Works fine!
```
The syntax error specifically occurs when the annotated assignment occurs after a `global` declaration in the program, even if the assignment is in a different scope.
Neither the docs nor the PEP say anything about such an ordering constraint.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34939>
_______________________________________
More information about the Python-bugs-list
mailing list