code: def ensure_str(s):
      r
      try:
          return s.decode()
      except AttributeError:
          if isinstance(s, str):
              return s
      return repr(s)
docs: r""" Ensure that s is a str and not a bytes (.decode() if necessary)
  
      >>> ensure_str(b"I'm 2. When I grow up I want to be a str!")
      "I'm 2. When I grow up I want to be a str!"
      >>> ensure_str(42)
      '42'