def do_int(value, default=0, base=10):
 try:
  if isinstance(value, string_types):
   return int(value, base)
  return int(value)
 except (TypeError, ValueError):
  try:
   return int(float(value))
  except (TypeError, ValueError):
   return default

def do_int ( value , default = 0 , base = 10 ) : try : if isinstance ( value , string_types ) : return int ( value , base ) return int ( value ) except ( TypeError , ValueError ) : try : return int ( float ( value ) ) except ( TypeError , ValueError ) : return default
convert the value into an integer .