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

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -