<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_soft(self, path_or_handle, as_gzip=False):
 """Save the object in a SOFT format. Args: path_or_handle (:obj:`str` or :obj:`file`):
 Path or handle to output file as_gzip (:obj:`bool`):
 Save as gzip """

        if isinstance(path_or_handle, str):
            if as_gzip:
                with gzip.open(path_or_handle, 'wt') as outfile:
                    outfile.write(self._get_object_as_soft())
            else:
                with open(path_or_handle, 'w') as outfile:
                    outfile.write(self._get_object_as_soft())
        else:
            path_or_handle.write(self._get_object_as_soft())