2011.04.10. 21:25 keltezéssel, Jason Swails írta:
Hello everyone,

This may sound like a bit of a strange desire, but I want to change the way in which a python program quits if an exception is not caught. The program has many different classes of exceptions (for clarity purposes), and they're raised whenever something goes wrong. Most I want to be fatal, but others I'd want to catch and deal with.
Well, the application quits when all of it threads are ended. Do you want to catch those exception only in the last threads? Or do you want to do it in all threads? Or just the main thread?
Is there any way to control Python's default exit strategy when it hits an uncaught exception (for instance, call another function that exits "differently")?
You can try the atexit module. But I think this is not what you want. I don't think that exceptions can be intercepted in unusual ways. "There should be only one obvious way to do it". Can you please write more about why isn't it good to use try /except?

An obvious way is to just catch every exception and manually call that function, but then I fill up my script with trys and excepts which hurts readability (and makes the code uglier) and quashes tracebacks; neither of which I want to do.
Okay, so maybe I misunderstood. You where talking about changing the way in which a python program quits. Can you please come up with an example and explain your problem in more detail?


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to