code: def strToBytes(value):
      '''
      :type value: ``str``
      :param value: value to encode
      '''
      kassert.is_of_types(value, (bytes, bytearray, six.string_types))
      if isinstance(value, six.string_types):
          return bytes(bytearray([ord(x) for x in value]))
      elif isinstance(value, bytearray):
          return bytes(value)
      return valuf strToBytes(value):
      '''
      :type value: ``str``
      :param value: value to encode
      '''
      kassert.is_of_types(value, (bytes, bytearray, six.string_types))
      if isinstance(value, six.string_types):
          return bytes(bytearray([ord(x) for x in value]))
      elif isinstance(value, bytearray):
          return bytes(value)
      return value
docs: :type value: ``str``
      :param value: value to encode