Commit 6e4da85e authored by Martin Claus's avatar Martin Claus

Added documentation to

parent 464c1d9b
Parse Fortran Namelists to dict-like objects and back
## Download
To get the latest git version do
$ git clone
## Usage
To parse a namelist file you call parse_namelist(fobj) where fobj is a file-like object offering a read() and seek() method (usually the standard python file object).
import namelist
with open(your_nml_file) as fobj:
nmls = namelist.parse_namelist_file(fobj)
nmls will be a list of instances of the Namelist class.
The Namelist class is a subclass of dict or OrderedDict if you use Python >= 2.7. A Namelist object, nml, is initialized with an name and optionally with initial values.
nml = Namelist("param", (("key1", val1), ...))
The name attribute will set the read-only property name of nml. To change, add or delete values the same methods are available as for dict.
nml.update({"eggs": 1, "spam": [1, 2, 3]})
To create a Fortran readable string representation of the Namelist instance, just use the str() build-in
s = str(nml)
or just
A string representation of the Namelist instance that can be used by eval() to create copies of it can be created by repr()
print repr(nml)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment