On 2010-12-02, Harishankar <v.harishan...@gmail.com> wrote: > I understand that the error vs exception debate is quite a big one in the > programming community as a whole and I don't consider myself very
Actually, I thought that debate was resolved years ago. I cannot think of a single recently developed programming language that does not provide exception handling mechanisms because they have been proven more reliable. > Python. I do understand both sides of the issue. Exceptions seem to be > generally more reliable but I feel they add a lot of complexity > particular when a lot of code is placed in a try block. Lines of code is one measure of complexity. Each line of code has a small chance of containing a bug. The more lines of code that you have, then the more likely that one of them contains a bug. Exceptions, by placing error handling code in fewer places, requires much fewer lines of code then requiring error handling code after each call that might produce an error condition. The operations of propogating an error up to the higher level logic of the program is another measure. In languages without exception handling, careful planning is needed to pass error conditions up through the call stack until they reach a high enough level in the logic that decisions can be made about how to handle them. Even further planning must be taken so that when the error condition reaches level where it needs to be handled, that enough information about the error is present to know exactly what went wrong so that it can figure out what to do about it. This usually involves using globals like errorno to pass out of band information about the error. Sometimes you even need to know about how the error affect intermediate levels, did the intermediate code attempt to handle the condtion and fail? The Openssl error handling system, that creates an error logging chain is an example of just how complex this can become. You gain all of this functionality automatically through exception mechanisms; without all of the complexity. -- http://mail.python.org/mailman/listinfo/python-list