From this issue
Your method is working and the Namelist object is being created. But I also have trouble with patching the original namelist file.
I can just read the source text, change the parameters and write it down, but this approach breaks the original formatting and comments. Therefore, I prefer patching.
Next code
f90nml.patch("/path/namelist_cfg", nml_cfg_edit, out_path="/path/namelist_cfg_tmplt")
causes next error: AttributeError: 'Cogroup' object has no attribute 'items'
From this issue