New submission from Michael Williamson:

In the docs for the try statement [1], part of the grammar is:

try1_stmt ::=  "try" ":" suite
               ("except" [expression ["as" target]] ":" suite)+
               ["else" ":" suite]
               ["finally" ":" suite]

The `target` rule allows any assignable expression (identifier, attributes, 
etc.). However, CPython appears to only allow identifiers as a target. The 
abstract grammar in the ast module [2] appears to confirm this.

[1] https://docs.python.org/3.4/reference/compound_stmts.html#the-try-statement
[2] https://docs.python.org/3.4/library/ast.html#abstract-grammar

----------
assignee: docs@python
components: Documentation
messages: 225611
nosy: docs@python, mwilliamson
priority: normal
severity: normal
status: open
title: Documentation on try statement incorrectly implies target of except 
clause can be any assignable expression
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22243>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to