I want to execute a python script that does something with several IP adresses. These adresses can be given via commad line.
I use the following command for parsing:
parser.add_argument('--IP',dest='Adresses',help='some Ips',
default=['192.168.2.15','192.168.2.3'],type=list,nargs='+')
However, when I run the script via command like the following:
python script.py --IP 192.168.2.15,192.168.2.3
It splits up the string after every character, the same behaviour occurs if I use a space instead of a comma, so if I print it out the following output happens
[['1', '9', '2', '.', '1', '6', '8', '.', '2', '.', '1', '5'], ['1', '9', '2', '.', '1', '6', '8', '.', '2', '.', '3']]
What I desire to have is:
['192.168.2.15','192.168.2.3']
like described in the default parameters
So two things I do not get to work here:
- How can I parse several strings to argparse but under one argument, so that it gets seperated in a list
- How can I stop the splitting up by characters
Thank you for your help