Ximo wrote:
> Hello, I'm programing an advanced calculator, and I have many problems with 
> the execution errors, specually with the division by 0.
> 
> And my question is how can show the execution error whitout exit of the 
> program, showing it in the error output as


Wrap the math in a try/except block such as:

# Handle the zero-division plus maybe some others:
exceptions_to_handle = (ZeroDivisionError,)

try:
        # do the math here
        result = eval(my_math)
except exceptions_to_handle, e:
        # gracefully handle here
        result = str(e)
# show the result in the calculator here
print result

... or something like that. The point is you need to handle the zero 
division error while not handling other, unexpected error conditions.



-- 
pkm ~ http://paulmcnett.com

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

Reply via email to