replace our single error string with the string representation of the exception argument. : Error Exception : Statement PYTHON TUTORIALS


PYTHON TUTORIALS » Statement » Error Exception »

 

replace our single error string with the string representation of the exception argument.


def safe_float(object):
  try:
      retval = float(object)
  except (ValueError, TypeError), diag:
      retval = str(diag)
  return retval

safe_float('xyz')
safe_float({})



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Statement
» Error Exception