Raise warning in Python without interrupting program
I am trying to raise a Warning in Python without making the program crash / stop / interrupt. I use the following simple function to check if the user passed a non-zero number to it. If so, the program should warn them, but continue as per normal. It should work like the code below, but should use class Warning(), Error() or Exception() instead of printing the warning out manually. def is_zero(i): if i != 0: print "OK" else: print "WARNING: the input is 0!" return i If I use the code below and pass 0 to the function, the program crashes and the value is never returned. Instead, I want the prog
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.