I was writing some python code earlier, and I noticed that in a code that
looks somwhat like this one :

    try:
        i = int("string")
        print("continued on")
        j = int(9.0)
    except ValueError as e:
        print(e)

>>> "invalid literal for int() with base 10: 'string'"

this code will handle the exception, but the code in the try block will not
continue.

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"
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to