On 5/6/2010 11:50 PM, Ben Cohen wrote:
Is there a pythonic way to collect and display multiple exceptions at
the same time?

For example let's say you're trying to validate the elements of a
list and you'd like to validate as many of the elements as possible
in one run and still report exception's raised while validating a
failed element.

eg -- I'd like to do something like this:

errors = []

 for item in data:
   try: process(item)
 except ValidationError as e:
   errors.append(e)

I believe each exception replaces the traceback message. So I would collect tracebacks rather than exceptions. Try the traceback module.

Terry Jan Reedy

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

Reply via email to