Just a little modification:

>>> tuple([(option, value) for option,value in zip(optionlist[0::2],optionlist[1::2])]) == tuple(zip(optionlist[0::2],optionlist[1::2]))
True

Indeed:

tuple(zip(optionlist[0::2],optionlist[1::2]))

shorter than:

tuple([(option, value) for option,value in zip(optionlist[0::2],optionlist[1::2])])


Karim

PS: I am from Grenoble, which place in France are from?

On 07/28/2011 06:37 PM, Nobody wrote:
On Thu, 28 Jul 2011 17:48:34 +0200, Web Dreamer wrote:

I would like to parse this TCL command line with shlex:

'-option1 [get_rule A1 B2] -option2 $VAR -option3 TAG'
s = s.replace('[','"[')
s = s.replace(']',']"')
Note that this approach won't work if you have nested brackets or braces.
That would require a real parser.


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to