code: def write(nml, nml_path, force=False, sort=False):
      
      # Promote dicts to Namelists
      if not isinstance(nml, Namelist) and isinstance(nml, dict):
          nml_in = Namelist(nml)
      else:
          nml_in = nml
  
      nml_in.write(nml_path, force=force, sort=sort)
docs: Save a namelist to disk using either a file object or its file path.
  
      File object usage:
  
      >>> with open(nml_path, 'w') as nml_file:
      >>>     f90nml.write(nml, nml_file)
  
      File path usage:
  
      >>> f90nml.write(nml, 'data.nml')
  
      This function is equivalent to the ``write`` function of the ``Namelist``
      object ``nml``.
  
      >>> nml.write('data.nml')
  
      By default, ``write`` will not overwrite an existing file.  To override
      this, use the ``force`` flag.
  
      >>> nml.write('data.nml', force=True)
  
      To alphabetically sort the ``Namelist`` keys, use the ``sort`` flag.
  
      >>> nml.write('data.nml', sort=True)