Help: Python for a big commercial project?
Boudewijn Rempt
boud at valdyas.org
Thu Apr 11 13:57:43 EDT 2002
Cameron Laird wrote:
> Let me reinforce this message.
>
> Python is indeed "not very good at low-level character
> manipulation" (and other operations) *in "typical C-style"*.
I'll deinforce it :-). I recently had occasion to write a
couple of scripts to convert my novel from it's usenet-style
markup to latex or html, and I copied Knode's usenet-markup
parser to Python. (I was pretty feverish at that time and not
able to think coherently. That's why I was coding instead of
writing.)
Anyway, this is a plain silly loop over every character in the
input files, like:
s = f.read()
i = 1
while i < len(s):
c = s[i]
if c == "<": # Comments are ignored
while c != ">":
i+=1
c=s[i]
elif c == "-":
if s[i+1] == "-" and s[i+2] != "-":
# mdash
...
But it still only takes 8 seconds to parse half a million
characters, which is pretty good going. I don't feel I will
have to do the rewrite I promised myself. After all, I'm
at 80% of the intended verbiage.
--
Boudewijn Rempt | http://www.valdyas.org
More information about the Python-list
mailing list