Re: Splitting a line while keeping quoted items together

2012-11-19 Thread Tim Chase
>> Use the "shlex" module in the std lib? > > Well color me ignorant. > > Works cleanly. I shouldn't have reinvented the wheel. I've experienced this enough: the csv module, option parsing, config-file parsing, logging, timeit, and pwd all come to mind as code I've written before realizing the s

Re: Splitting a line while keeping quoted items together

2012-11-19 Thread Steven D'Aprano
On Mon, 19 Nov 2012 16:05:30 -0800, josh wrote: > I am working on a cmd.Cmd-based program, and normally could just split > the string and get the right parts. > > Now I have a case where I could have two or three words in the string > that need to be grouped into the same thing. Try shlex.split.

re[2]: Splitting a line while keeping quoted items together

2012-11-19 Thread Joshua R English
Well color me ignorant. Works cleanly. I shouldn't have reinvented the wheel. Thanks.   This seem really ugly. Is there a cleaner way to do this? Is there a keyword I could search by to find something nicer? Use the "shlex" module in the std lib? Cheers, Chris -- Cheers,Chris--http://rebertia.

Re: Splitting a line while keeping quoted items together

2012-11-19 Thread Chris Rebert
On Monday, November 19, 2012, wrote: > I am working on a cmd.Cmd-based program, and normally could just split the > string and get the right parts. > > Now I have a case where I could have two or three words in the string that > need to be grouped into the same thing. > > Then I realized that I'm

Splitting a line while keeping quoted items together

2012-11-19 Thread josh
I am working on a cmd.Cmd-based program, and normally could just split the string and get the right parts. Now I have a case where I could have two or three words in the string that need to be grouped into the same thing. Then I realized that I'm not the only person who has had to deal with thi