Replies: 1 comment
-
|
While there is nothing wrong with a system exit, here is how you can catch it and run some clean up code. This could be to say something nice instead of the traceback, or to return motors to a starting position for example before properly exiting. from pybricks.tools import wait
def main_program():
print("For a moment, nothing happened.")
wait(10000)
print("Then, after 10 seconds or so, nothing continued to happen.")
try:
main_program()
except SystemExit:
print("So long, and thanks for all the fish!")Try letting it exit normally, and then try it by pressing the button (or add |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a function that stop the program even if its in the middle of the program? I've tried 'Systemexit()' however this doesn't do anything and I've tried 'raise systemexit' which works but it also writes 'traceback ...' after in the terminal (I know I'm being picky here). Is there a way to like after a if statement do like 'if len(input) != 2: ,,,stop the program'''
Beta Was this translation helpful? Give feedback.
All reactions