I am newly converting to Python and want to know how to stop or pause in a script for diagnostic purposes. For instance, I want to do something like:
If Condition_is_True:
Statement
else:
print('Condition not met!')
stop
I guess I can use the try: except:
statement, but the condition won't raise an exception; or I can use a while
statement, but it won't stop.
I knew I could also use the debugger (import pdb; pdb.set_trace()
), but I don't want to keep the debugger in the code permanently. Is there a better way to do this?