Exit python properly -


i knew sys.exit() raises exit exception, when run knew wouldn't exit:

in [25]: try:    ....:     sys.exit()    ....: except:    ....:     print "oops"    ....:      oops 

but thought os._exit() meant exit using c call, it's causing exception:

in [28]: try:    ....:     os._exit()    ....: except:    ....:     print "oops"    ....:      oops 

is there way of doing without killing pid?

don't use except without exception class, sys.exit work fine without triggering exception handling:

>>> import sys >>> try: ...     sys.exit() ... except exception: ...     print 'oops' ...  $  

there other exceptions triggered plain except clause (and in general shouldn't), keyboardinterrupt.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

java - stack overflow exception on xml transformation -