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.
To be fair, I suspect the issue was there were two calls to int() there that might raise a ValueError, and the OP wanted to catch them with one except, so you would need to do somethign like:
try: i = int("string") except ValueError as e: print(e) print("continued on") try: j = int(9.0) except ValueError as e: print(e)
Which can seem a bit verbose, but in fact, there are a number of ways one might want to proceed with/without an error, and the current except, finally, else options cover them all in a clearly defined way.
~Amber _______________________________________________ Python-ideas mailing list Pythonfirstname.lastname@example.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/