How do I speedup this loop?
Steve
nospam at nopes
Thu Jul 15 19:57:54 EDT 2004
Jean Brouwers wrote:
> What about handling all output as one string?
>
> script = os.popen('some command')
> script = script.replace("'", "\\'") # replace ' with \'
> script = script.replace("\r", ") # remove cr
> script = script.replace("\\n", "$___n") # replace \n
> script = script.replace("\n", "@___n'") # replace nl
>
This won't do any better than what I was already doing. I need the code
to be very fast and this will only end up creating a lot of copies
everytime the string is going to be modified (strings are immutable). I
really like the idea of using regex for this (proposed by lonnie), but I
still need to a hang of it.
Cheers,
Steve
------------ And now a word from our sponsor ------------------
Want to have instant messaging, and chat rooms, and discussion
groups for your local users or business, you need dbabble!
-- See http://netwinsite.com/sponsor/sponsor_dbabble.htm ----
More information about the Python-list
mailing list