py-hostlist processes slurm-style hostlist strings and can return those strings in manipulated fashion.
Get py-hostlist from the github repository:
$ git clone https://github.com/llnl/py-hostlist.git $ cd py-hostlist
From here, build and install the package on your machine:
$ python setup.py sdist bdist_wheel $ pip install dist/py_hostlist-0.0.1.dev0-py2.py3-none-any.whl
Now you can start using it!
$ hostlist -h