questions about Exceptions?
skanemupp at yahoo.se
skanemupp at yahoo.se
Thu Apr 10 04:15:19 EDT 2008
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?
More information about the Python-list
mailing list