posargs2str

opthandler.posargs2str(posargs, prec=3)[source]

Convert a list of positional arguments to a string.

Parameters:
  • posargs (iterable) – The list of positional arguments.

  • prec (int, optional) – The number of decimal places to use for floating point numbers.

Returns:

posargs (str) – The positional arguments as string.

Notes

This function is meant to generate a string of positional arguments that can be parsed to the Slurm job scripts of this project.

True/False are converted to '1'/'0'.

Examples

>>> posargs = ["in", "out", 0, 12.345, 12.344, True, "arg1 arg2"]
>>> posargs2str(posargs, prec=2)
"in out 0 12.35 12.34 1 'arg1 arg2'"