On 12/16/2010 7:33 PM, Steven D'Aprano wrote:

Python's exception system has to handle two different situations: buggy
code, and bad data. It's not even clear whether there is a general
distinction to be made between the two, but even if there's not a general
distinction, there's certainly a distinction which we can *sometimes*
make.

The two are intertwined. Production code that passes bad data to a function without catching the exception is buggy.


def func(x):
     if !(x<= 10):
         if x%2 != 0:
             pass
         else:
             raise ValueError('bad value for x')
     return

I would have got the same traceback,

A traceback is printed only if the code passes bad data and does not catch the exception. Tracebacks are for developers, not for users.

--
Terry Jan Reedy

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

Reply via email to