def get_status_code_from_code_response(code):
 last_valid_line_from_code = [line for line in code.split(u'\n') if line][(-1)]
 status_code_from_last_line = int(last_valid_line_from_code.split()[0])
 status_code_from_first_digits = int(code[:3])
 if (status_code_from_last_line != status_code_from_first_digits):
  log.warning(u'FTP response status code seems to be inconsistent.\nCode received: %s, extracted: %s and %s', code, status_code_from_last_line, status_code_from_first_digits)
 return status_code_from_last_line

def get_status_code_from_code_response ( code ) : last_valid_line_from_code = [ line for line in code . split ( u'\n' ) if line ] [ ( - 1 ) ] status_code_from_last_line = int ( last_valid_line_from_code . split ( ) [ 0 ] ) status_code_from_first_digits = int ( code [ : 3 ] ) if ( status_code_from_last_line != status_code_from_first_digits ) : log . warning ( u'FTP response status code seems to be inconsistent.\nCode received: %s, extracted: %s and %s' , code , status_code_from_last_line , status_code_from_first_digits ) return status_code_from_last_line
the idea is to handle complicated code response .