Aug-18-2017, 04:39 PM
If you're getting an error, and want to handle it safely, then you're looking for exception handling: https://docs.python.org/3/tutorial/errors.html
>>> def i_always_fail(): ... print("here we go!") ... raise Exception("dead") ... >>> i_always_fail() here we go! Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in i_always_fail Exception: dead >>> try: ... i_always_fail() ... except Exception as err: ... print("Error happened: {}".format(err)) ... here we go! Error happened: dead