code: def write(self, nml_path, force=False, sort=False):
          
          nml_is_file = hasattr(nml_path, 'read')
          if not force and not nml_is_file and os.path.isfile(nml_path):
              raise IOError('File {0} already exists.'.format(nml_path))
  
          nml_file = nml_path if nml_is_file else open(nml_path, 'w')
          try:
              self._writestream(nml_file, sort)
          finally:
              if not nml_is_file:
                  nml_file.close()
docs: Write Namelist to a Fortran 90 namelist file.
  
          >>> nml = f90nml.read('input.nml')
          >>> nml.write('out.nml')