On 2019-07-26 19:26, Serhiy Storchaka wrote:
[snip]
I propose to add "except" clause to "for" and "with" statement to catch
exceptions in the code that can't be wrapped with "try ... except".
for VAR in EXPR:
BLOCK
except EXC:
HANDLER
should be equivalent to
try:
_it = iter(EXPR)
except EXC:
HANDLER
else:
while True:
try:
VAR = next(_it)
except StopIteration:
break
except EXC:
HANDLER
break
BLOCK
[snip]
1. The 'for' loop can have an 'else' clause, and so can the 'try'
statement. Is there any ambiguity over its meaning?
2. In your example you have it catching the exception if EXPR or
iter(EXPR) raises. Is that a good idea?
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/QGJDHMK5LU55RAIAVCLFTPRUEBVOJ7U6/
Code of Conduct: http://python.org/psf/codeofconduct/