is there a general philosophy as to when to use exceptions and when
not to?

like here:
def Calc():
    global nbr
    try:
        print eval(nbr)
    except:
        print "Not computable"
    nbr = ""

i have a calculator and nbr is a string that contains '0123456789+-*/'

if the string ends on +-*/ it will throw an exception(unexpected EOF).

i could easily prevent the exceptions here with an if-statement, is
that preferrable and why?


also when u throw exceptions should u catch the speicfic one? i guess
only if u want it to do soemthing special since  catching only only
one exception logicall would abort the program if another one is
thrown?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to