On Sat, Jan 5, 2019 at 4:39 PM Simon <[email protected]> wrote:
> I propose to be able to use the continue keyword to continue the execution
> of the try block even when an error is handled. The above could then be
> changed to :
>
>
> try:
> i = int("string")
> print("continued on")
> j = int(9.0)
> except ValueError as e:
> print(e)
> continue
>
> >>> "invalid literal for int() with base 10: 'string'"
> >>> "continued on"
>
There is already a much simpler way of doing this:
try:
i = int("string")
except ValueError as e:
print(e)
print("continued on")
j = int(9.0)
The point of the 'try' block is to encapsulate the code you want to *stop*
executing if an exception is raised. If you want code to be run regardless
of whether an exception is raised, move it past the try-except.
~Amber
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/