docs: def save(self, target_file=None, as_template=False):
          """
          Save the config
  
          :param str target_file: File to save to. Defaults to `self._last_source` if set
          :param bool as_template: Save the config with all keys and sections commented out for user to modify
          :raise AttributeError: if target file is not provided and `self._last_source` is not set
          """
          self._read_sources()
  
          if not target_file:
              if not self._last_source:
                  raise AttributeError('Target file is required when last source is not set during instantiation')
              target_file = self._last_source
  
          output = str(self)
  
          if as_template:
              output_tmpl = []
              for line in output.split('\n'):
                  if line and not line.startswith('#'):
                      line = '# %s' % line
                  output_tmpl.append(line)
              output = '\n'.join(output_tmpl)
  
          with open(target_file, 'w') as fp:
              fp.write(output)