I have the following string in Python :
l='-n context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"] -t "SRC mask interpolated to DST"'
I want to split it in a list, with this result :
['-n', 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]', '-t', '"SRC mask interpolated DST"']
i.e, I need a split that won't split between "
With l.split() I get :
['-n', 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]', '-t', '"SRC', 'mask', 'interpolated', 'to', 'DST"']
In fact, I want' the result that sys.argv will give with this string on the command line :
python '-n context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"] -t "SRC mask interpolated to DST"'
sys.argv is :
['-n', 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]', '-t', 'SRC mask interpolated DST']
sys.arg has even removed the " in the last string
N.B : the first part is the syntax of an xml node as understood by xml.etree.ElementTree module
Any hint?