def saverc(filename, dat, overwrite=False):
filename = os.path.expanduser(os.path.expandvars(filename))<EOL>if not overwrite and os.path.isfile(filename):<EOL><INDENT>raise ValueError('<STR_LIT>' % filename)<EOL><DEDENT>if not pimms.is_map(dat):<EOL><INDENT>try: dat = dict(dat)<EOL>except Exception: raise ValueError('<STR_LIT>')<EOL><DEDENT>with open(filename, '<STR_LIT:w>') as fl:<EOL><INDENT>json.dump(dat, fl, sort_keys=True)<EOL><DEDENT>return filename<EOL>
saverc(filename, d) saves the given configuration dictionary d to the given filename in JSON
  format. If d is not a dictionary or if filename already exists or cannot be created, an error
  is raised. This funciton does not create directories.

The optional argument overwrite (default: False) may be passed as True to overwrite files that
already exist.