I have some scripts that utilize several if statements. If the script enters a certain one of the if statements, I want the script to stop execution and exit. I’ve been doing this with
from sys import exit
Do I need to do this, or is there a better, more appropriate way to do this?
You can simply call “return” to exit from the script at any point.
I think this will work, but only if I define the entire script as a function. Just in case someone else wonders about this.
What did you end up doing?
Is exit() okay?
Do I have to import that library?
I have people submitting, but I want them not to be able to if some values are null.
I don't import the library and use exit(), seems to work, but I don't know if that means it is the way to perform the script.
Validate that all fields that you need are not null and then execute, otherwise just fall through. Though you should give the user some indication of why there submission was not accepted.
Yah, I should make some exception logic that sets text.
If I could just remember where you showed me that.
I remember seeing it, and even implementing it for a time once.