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

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -