I have a string which I am parsing using ConfigParser. This string contains some options for a process to run. I want to construct a List from this string.
argString="-i,1,-m,2,-trace,on,-setlimit,500"
argList=['-i','1','-m','2','-trace','on','-setlimit','500']
I am using this list to execute with subprocess Popen. basically, how do I append a List by reading a string and given separator ',' or is there a better way to do it using ConfigParser?
I think you want str.split
:
>>> argString="-i,1,-m,2,-trace,on,-setlimit,500"
>>> argString.split(",")
['-i', '1', '-m', '2', '-trace', 'on', '-setlimit', '500']