<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self, path=None):
 """ Write config data to disk. If this config object already has a path, it will write to it. If it doesn't, one must be passed during this call. :param str path: path to config file """

        if not self._path and not path:
            raise ConfigException('no config path given')
        if path:
            self._path = path
        if '~' in self._path:
            self._path = os.path.expanduser(self._path)
        f = open(self._path, 'w')
        f.write(json.dumps(self._data))
        f.close()