shlex parsing

Karim karim.liateni at free.fr
Thu Jul 28 13:51:10 EDT 2011


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.
>




More information about the Python-list mailing list