def numericise(value, empty2zero=False, default_blank=''):
 if (value is not None):
  try:
   value = int(value)
  except ValueError:
   try:
    value = float(value)
   except ValueError:
    if (value == ''):
     if empty2zero:
      value = 0
     else:
      value = default_blank
 return value

def numericise ( value , empty2zero = False , default_blank = '' ) : if ( value is not None ) : try : value = int ( value ) except ValueError : try : value = float ( value ) except ValueError : if ( value == '' ) : if empty2zero : value = 0 else : value = default_blank return value
returns a value that depends on the input string: - float if input can be converted to float - integer if input can be converted to integer - zero if the input string is empty and empty2zero flag is set - the same input string .