@10, your second question has a solution but it is a bit advanced. Here's how you do that though:
The sys function has a variable, excepthook, which defines what the application will do when an exception is thrown and not caught by any try blocks in the program. As with anything in Python bar tuples, this particular value is mutable. The function looks like this:
excepthook(exctype, value, traceback)
That means that, should you modify this variable to point to another function, it must follow a similar signature: it must take only the parameters in the function above. The parameters mean the following:
* exctype: the type of exception being thrown. This can be something like KeyboardInterrupt, which is not an exception that you should treat as an actual error, or it can be an actual exception, such as ValueError, SyntaxError, UnboundLocalError, and so on. (Yes, the syntax error messages you get are, in fact, exceptions in Python. I would not, however, ignore them.)
* value: The instance of this exception. Use this when reporting errors; it will contain the actual message of the exception.
* traceback: the tracebak (in full). You may also use this, if you like, though beware that it will reveal code lines. Its very useful in debugging your code, but not very useful in release builds.
"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." — Charles Babbage.