Python how to exit main function -
Python how to exit main function -
possible duplicates: terminating python script terminating python programme
my question how exit out in python main function? have tried 'return' gave error syntaxerror: 'return' outside function. can help? thanks.
if __name__ == '__main__': try: if condition: (i want exit here) finally:
you can utilize sys.exit() exit middle of main function.
however, recommend not doing logic there. instead, set in function, , phone call __main__ - can utilize homecoming normal.
python
Comments
Post a Comment