code: def byte_str(s="", encoding="utf-8", input_encoding="utf-8", errors="strict"):
      
      assert isinstance(s, basestring)
      if isinstance(s, unicode):
          return s.encode(encoding, errors)
      if s and encoding != input_encoding:
          return s.decode(input_encoding, errors).encode(encoding, errors)
      return s
docs: Returns a byte string version of 's', encoded as specified in 'encoding'.
  
      Accepts str & unicode objects, interpreting non-unicode strings as byte
      strings encoded using the given input encoding.