read_python_params_file
- PlasmaCalcs.tools.io_tools.read_python_params_file(filename, *, eval=True, as_tuples=False)
parse python file of params into a python dictionary of params.
(only eval occurs via ast.literal_eval; does not evaluate arbitrary code.)- filename: string
- file to read from.
- eval: bool, default True
- whether to attempt to evaluate the values,using ast.literal_eval (safer but less flexible than eval).if True, try to evaluate values but use strings if evaluation fails.if False, values will remain as strings.
- as_tuples: bool, default False
- if True, return list of tuples instead of dictionary.list of tuples guaranteed to appear in the same order as in the params file.
File formatting notes:- hashtags (#) are used for comments. (python format)- ignore blank lines & lines that don’t assign a variable (missing ‘=’)- ignores all leading & trailing whitespace in vars & values.