{"id":23698,"library":"f90nml","title":"f90nml","description":"A Python module for reading and writing Fortran 90 namelist files. Current version is 1.5 with irregular release cadence. Supports parsing, modifying, and writing namelist files, preserving structure and comments.","status":"active","version":"1.5","language":"python","source_language":"en","source_url":"https://github.com/marshallward/f90nml","tags":["fortran","namelist","parser","io"],"install":[{"cmd":"pip install f90nml","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Wrong because f90nml uses a module-level API; direct import of parse may be unconventional.","wrong":"from f90nml import parse","symbol":"f90nml","correct":"import f90nml"}],"quickstart":{"code":"import f90nml\nimport os\n\n# Read a namelist file\nnml = f90nml.read('path/to/namelist')\n\n# Access a variable\nprint(nml['namelist_name']['variable_name'])\n\n# Write back\nnml.write('output.nml')\n\n# Create from dict\ndata = {'namelist': {'var1': 1.0, 'var2': 2}}\nnml = f90nml.Namelist(data)\nnml.write('new.nml')","lang":"python","description":"Basic usage: read, modify, write namelist files."},"warnings":[{"fix":"Use: with open('file.nml', 'w') as f: nml.write(f)","message":"The write() method with a file path is deprecated in favor of using open() and write() with a file object.","severity":"deprecated","affected_versions":">=1.4"},{"fix":"Handle duplicate keys via f90nml.Cogroup or use nml.todict() with dups=True to get list representation.","message":"Duplicate keys behavior changed: in version 1.4, duplicate keys are now stored as Cogroup objects, not lists. Code expecting plain lists will break.","severity":"breaking","affected_versions":">=1.4"},{"fix":"Use custom formatting or work with string representation if needed.","message":"Empty lists in namelist are formatted as comma-delimited blanks (e.g., ',,') instead of an empty line. This can cause confusion when re-parsing.","severity":"gotcha","affected_versions":">=1.4.1"},{"fix":"Manually convert string values to lowercase/uppercase as needed.","message":"The parser treats unquoted strings case-sensitively. Fortran normally treats them case-insensitively, leading to unexpected mismatches.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from f90nml import Namelist or f90nml.Namelist","cause":"Typo in class name: correct is 'Namelist' with capital 'N'.","error":"AttributeError: module 'f90nml' has no attribute 'Namelist'"},{"fix":"Use: with open('file.nml', 'w') as f: nml.write(f)","cause":"Passing a file object to write() without specifiying mode 'w' or using deprecated string path.","error":"TypeError: write() argument must be str, not _io.TextIOWrapper"},{"fix":"Ensure all namelist group and variable names are strings.","cause":"Keys passed to Namelist constructor or assignments must be strings.","error":"ValueError: Invalid key: 'mykey' - key must be a string"},{"fix":"Use: nml['group']['key'].extend([value]) or nml['group']['key'] = f90nml.Cogroup([value1, value2])","cause":"Cogroup does not support append; use list-like indexing or extend.","error":"AttributeError: 'Cogroup' object has no attribute 'append'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}