code: def format_val(val):
      
      val = text_type(val)
      if val.isdigit():
          return int(val)
      else:
          return '\'{0}\''.format(val)
docs: Returns val as integer or as escaped string according to its value
      :param val: any value
      :return: formatted string