docs: def saverc(filename, dat, overwrite=False):
      '''
      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.
      '''
      filename = os.path.expanduser(os.path.expandvars(filename))
      if not overwrite and os.path.isfile(filename):
          raise ValueError('Given filename %s already exists' % filename)
      if not pimms.is_map(dat):
          try: dat = dict(dat)
          except Exception: raise ValueError('Given config data must be a dictionary')
      with open(filename, 'w') as fl:
          json.dump(dat, fl, sort_keys=True)
      return filename