<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def default( self, o ):
 """If o is a datetime object, convert it to an ISO string. If it is an exception, convert it to a string. If it is a numpy int, coerce it to a Python int. :param o: the field to serialise :returns: a string encoding of the field"""

        if isinstance(o, datetime):
            # date/time, return an ISO formatted string
            return o.isoformat()
        else:
            if isinstance(o, Exception):
                # exception, stringify it
                return str(o)
            else:
                if isinstance(o, numpy.integer):
                    # numpy ints inherit differently between Python 2 and 3
                    # see https://bugs.python.org/issue24313
                    return int(o)
                else:
                    # everything else, pass through
                    return super(MetadataEncoder, self).default(o)