From: James Stroud on 7 Apr 2010 22:02 Patrick Maupin wrote: > BTW, although I find it annoying when people say "don't do that" when > "that" is a perfectly good thing to do, and although I also find it > annoying when people tell you what not to do without telling you what > *to* do, and although I find the regex solution to this problem to be > quite clean, the equivalent non-regex solution is not terrible I propose a new way to answer questions on c.l.python that will (1) give respondents the pleasure of vague admonishment and (2) actually answer the question. The way I propose utilizes the double negative. For example: "You are doing it wrong! Don't not do <code>re.split('\s{2,}', s[2])</code>." Please answer this way in the future. Thank you, James
From: Patrick Maupin on 7 Apr 2010 22:10 On Apr 7, 9:02 pm, James Stroud <nospamjstroudmap...(a)mbi.ucla.edu> wrote: > Patrick Maupin wrote: > > BTW, although I find it annoying when people say "don't do that" when > > "that" is a perfectly good thing to do, and although I also find it > > annoying when people tell you what not to do without telling you what > > *to* do, and although I find the regex solution to this problem to be > > quite clean, the equivalent non-regex solution is not terrible > > I propose a new way to answer questions on c.l.python that will (1) give respondents the pleasure of vague admonishment and (2) actually answer the question. The way I propose utilizes the double negative. For example: > > "You are doing it wrong! Don't not do <code>re.split('\s{2,}', s[2])</code>." > > Please answer this way in the future. I most certainly will not consider when that isn't warranted! OTOH, in general I am more interested in admonishing the authors of the pseudo-answers than I am the authors of the questions, despite the fact that I find this hilarious: http://despair.com/cluelessness.html Regards, Pat
From: Grant Edwards on 7 Apr 2010 22:36 On 2010-04-08, Patrick Maupin <pmaupin(a)gmail.com> wrote: > On Apr 7, 4:47?pm, Grant Edwards <inva...(a)invalid.invalid> wrote: >> On 2010-04-07, J <dreadpiratej...(a)gmail.com> wrote: >> >> > Can someone make me un-crazy? >> >> Definitely. ?Regex is driving you crazy, so don't use a regex. >> >> ? inputString = "# 1 ?Short offline ? ? ? Completed without error ? ? 00% ? ? ? 679 ? ? ? ? -" >> >> ? print ' '.join(inputString.split()[4:-3]) [...] > OK, fine. Post a better solution to this problem than: > >>>> import re >>>> re.split(' {2,}', '# 1 Short offline Completed without error 00%') > ['# 1', 'Short offline', 'Completed without error', '00%'] OK, I'll bite: what's wrong with the solution I already posted? -- Grant
From: Grant Edwards on 7 Apr 2010 22:38 On 2010-04-08, James Stroud <nospamjstroudmapson(a)mbi.ucla.edu> wrote: > Patrick Maupin wrote: >> BTW, although I find it annoying when people say "don't do that" when >> "that" is a perfectly good thing to do, and although I also find it >> annoying when people tell you what not to do without telling you what >> *to* do, and although I find the regex solution to this problem to be >> quite clean, the equivalent non-regex solution is not terrible > > I propose a new way to answer questions on c.l.python that will (1) give respondents the pleasure of vague admonishment and (2) actually answer the question. The way I propose utilizes the double negative. For example: > > "You are doing it wrong! Don't not do <code>re.split('\s{2,}', s[2])</code>." > > Please answer this way in the future. I will certain try to avoid not answering in a manner not unlike that. -- Grant
From: Patrick Maupin on 7 Apr 2010 22:45 On Apr 7, 9:36 pm, Grant Edwards <inva...(a)invalid.invalid> wrote: > On 2010-04-08, Patrick Maupin <pmau...(a)gmail.com> wrote:> On Apr 7, 4:47?pm, Grant Edwards <inva...(a)invalid.invalid> wrote: > >> On 2010-04-07, J <dreadpiratej...(a)gmail.com> wrote: > > >> > Can someone make me un-crazy? > > >> Definitely. ?Regex is driving you crazy, so don't use a regex. > > >> ? inputString = "# 1 ?Short offline ? ? ? Completed without error ? ? 00% ? ? ? 679 ? ? ? ? -" > > >> ? print ' '.join(inputString.split()[4:-3]) > > [...] > > > OK, fine. Post a better solution to this problem than: > > >>>> import re > >>>> re.split(' {2,}', '# 1 Short offline Completed without error 00%') > > ['# 1', 'Short offline', 'Completed without error', '00%'] > > OK, I'll bite: what's wrong with the solution I already posted? > > -- > Grant Sorry, my eyes completely missed your one-liner, so my criticism about not posting a solution was unwarranted. I don't think you and I read the problem the same way (which is probably why I didn't notice your solution -- because it wasn't solving the problem I thought I saw). When I saw "And I am interested in the string that appears in the third column, which changes as the test runs and then completes" I assumed that, not only could that string change, but so could the one before it. I guess my base assumption that anything with words in it could change. I was looking at the OP's attempt at a solution, and he obviously felt he needed to see two or more spaces as an item delimiter. (And I got testy because of seeing other IMO unwarranted denigration of re on the list lately.) Regards, Pat
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: remote multiprocessing, shared object Next: ftp and python |