Re: parse a string of parameters and values

2009-12-14 Thread Tim Chase
Gabriel Genellina wrote: Peter Otten escribió: bsneddon wrote: I am going to read a text file that is an export from a control system. It has lines with information like base=1 name="first one" color=blue I would like to put this info into a dictionary for processing. import shlex s = 'base=

Re: parse a string of parameters and values

2009-12-14 Thread Gabriel Genellina
En Sun, 13 Dec 2009 07:28:24 -0300, Peter Otten <__pete...@web.de> escribió: bsneddon wrote: I am going to read a text file that is an export from a control system. It has lines with information like base=1 name="first one" color=blue I would like to put this info into a dictionary for proc

Re: parse a string of parameters and values

2009-12-13 Thread bsneddon
On Dec 13, 5:28 am, Peter Otten <__pete...@web.de> wrote: > bsneddon wrote: > > I have a problem that I can come up with a brute force solution to > > solve but it occurred to me that there may be an > >  "one-- and preferably only one --obvious way to do it". > > > I am going to read a text file t

Re: parse a string of parameters and values

2009-12-13 Thread Peter Otten
bsneddon wrote: > I have a problem that I can come up with a brute force solution to > solve but it occurred to me that there may be an > "one-- and preferably only one --obvious way to do it". > > I am going to read a text file that is an export from a control > system. > It has lines with info

Re: parse a string of parameters and values

2009-12-12 Thread Steven D'Aprano
On Sun, 13 Dec 2009 05:52:04 +, John Machin wrote: > Steven D'Aprano REMOVE-THIS-cybersource.com.au> writes: [snip] >> If you have multiple keys per line, you need a more sophisticated way >> of splitting them. Something like this should work: [...] > There appears to be a problem with the ab

Re: parse a string of parameters and values

2009-12-12 Thread John Machin
Steven D'Aprano REMOVE-THIS-cybersource.com.au> writes: > > On Sat, 12 Dec 2009 16:16:32 -0800, bsneddon wrote: > > > > I am going to read a text file that is an export from a control system. > > It has lines with information like > > > > base=1 name="first one" color=blue > > > > I would l

Re: parse a string of parameters and values

2009-12-12 Thread Steven D'Aprano
On Sat, 12 Dec 2009 16:16:32 -0800, bsneddon wrote: > I have a problem that I can come up with a brute force solution to solve > but it occurred to me that there may be an > "one-- and preferably only one --obvious way to do it". I'm not sure that "brute force" is the right description here. Gen

parse a string of parameters and values

2009-12-12 Thread bsneddon
I have a problem that I can come up with a brute force solution to solve but it occurred to me that there may be an "one-- and preferably only one --obvious way to do it". I am going to read a text file that is an export from a control system. It has lines with information like base=1 name="firs