Text Parsing - character at a time...
peter at engcorp.com
Fri Jul 9 13:58:21 CEST 2004
> I'm parsing character by character and adding the characters of the
> input string to the output until I come to ones I want to modify.
> What's an efficient equivalent in python ?
I think the answer might depend on information you haven't provided.
How are you 'parsing' this? In other words, how do you know
when you've gotten to the "ones you want to modify"? Are you sure
there isn't a way of avoiding the one-by-one manual scan? If
there is, you can probably add characters whole sequences at a
time to a list, as you suggest, by slicing from the input string
once you know where a sequence of "kept" characters starts
For that matter, could you use string.replace or re.sub to do
the job even more efficiently?
More information about the Python-list