I would like to pass arguments to a python script as follows.
python test.py --env_a 5 --env_b 8
So that all the arguments beginning with "env" are added to a dictionary like:
env = {
"a": 5,
"b": 8
}
Of course the whole point is that the number and the names of those arguments are not predefined.
Do you know if this is possible or if there is a better way of doing this?
I am using argparse so something along the lines of
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--env-*", type=dict, default=0)
args = parser.parse_args()
print(args.env)
would be ideal.
--env=a:5