<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _from_python(self, value):
 """ Converts python values to a form suitable for insertion into the xml we send to solr. """

        if hasattr(value, 'strftime'):
            if hasattr(value, 'hour'):
                offset = value.utcoffset()
                if offset:
                    value = value - offset
                value = value.replace(tzinfo=None).isoformat() + 'Z'
            else:
                value = "%sT00:00:00Z" % value.isoformat()
        elif isinstance(value, bool):
            if value:
                value = 'true'
            else:
                value = 'false'
        else:
            if IS_PY3:
                # Python 3.X
                if isinstance(value, bytes):
                    value = str(value, errors='replace')  # NOQA: F821
            else:
                # Python 2.X
                if isinstance(value, str):
                    value = unicode(value, errors='replace')   # NOQA: F821

            value = "{0}".format(value)

        return clean_xml_string(value)