Mega Code Archive
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({})