def get_http_status(status_code, default_reason='Unknown'):
 try:
  code = float(status_code)
  code = int(code)
  if (code < 100):
   raise ValueError
 except ValueError:
  raise ValueError('get_http_status failed: "%s" is not a valid status code', status_code)
 try:
  return getattr(status_codes, ('HTTP_' + str(code)))
 except AttributeError:
  return ((str(code) + ' ') + default_reason)

def get_http_status ( status_code , default_reason = 'Unknown' ) : try : code = float ( status_code ) code = int ( code ) if ( code < 100 ) : raise ValueError except ValueError : raise ValueError ( 'get_http_status failed: "%s" is not a valid status code' , status_code ) try : return getattr ( status_codes , ( 'HTTP_' + str ( code ) ) ) except AttributeError : return ( ( str ( code ) + ' ' ) + default_reason )
gets both the http status code and description from just a code args: status_code: integer or string that can be converted to an integer default_reason: default text to be appended to the status_code if the lookup does not find a result returns: str: status code e .