I have the following python argparse parser:
pointparser = argparse.ArgumentParser(add_help=False)
pointparser.add_argument("-a", "--a_value", default="NaN", nargs="?",
type=float)
pointparser.add_argument("-b", "--b_value", default="NaN", nargs="?",
type=float)
...
pointparser.add_argument("-j", "--j_value", default="NaN", nargs="?",
type=float)
data_point = pointparser.parse_args(parameterlist)
datapoint=[data_point.a_value, data_point.b_value, data_point.c_value,
data_point.d_value, data_point.e_value, data_point.f_value,
data_point.g_value, data_point.h_value, data_point.i_value,
data_point.j_value]
Is it possible to loop over the arguments a-j and directly store them in a list. That way, I could leave the number of arguments open, i.e. only go to -c or even to -k
python yourthing.py one two threeand get a list['one', 'two', 'three']?datapointand anotherdata_point.nargsis a little odd. There doesn't seem to be any reason to specify the options without an argument, since it accomplishes the same thing as not specifying it at all.