Re: Program inefficiency?



thebjorn wrote:
On Sep 29, 5:22 pm, hall.j...@xxxxxxxxx wrote:
I wrote the following simple program to loop through our help files
and fix some errors (in case you can't see the subtle RE search that's
happening, we're replacing spaces in bookmarks with _'s)
(...)

Ugh, that was entirely too many regexps for my taste :-)

How about something like:

def attr_ndx_iter(txt, attribute):
(...)
def substr_map(txt, indices, fn):
(...)
def transform(s):
(...)
def zap_spaces(txt, *attributes):
(...)
def mass_replace():
(...)

Oh yeah, now it's clear as mud.
I do think that the whole program shouldn't take more than 10 lines of code using one sensible regex (impossible to define without knowing the real input and output formats).
And (sorry to tell) I'm convinced this is a problem for regexes, in spite of anybody's personal taste.

Pablo
.



Relevant Pages

  • Re: Program inefficiency?
    ... we're replacing spaces in bookmarks with _'s) ... def attr_ndx_iter: ... cur = j ...
    (comp.lang.python)
  • Re: Program inefficiency?
    ... we're replacing spaces in bookmarks with _'s) ... def substr_map: ... I have no doubt that it would be possible to do with a single regex. ...
    (comp.lang.python)