[EMAIL PROTECTED] wrote: > Cheers for the reply. > > But I'm still having a spot of bother with the === addition > > it would seem that if there is no whitespace after the ===test > then the new === gets added to the next line > > e.g file contains: > > ===test (and then no whitesapace/carriage returns or anything) > > and the result is: > > ===test > ===
You'd get the above with Fredrik's solution if there is a newline. That's why I put in the rstrip() method call (which removes trailing whitespace) and added an explicit "\n" (the Python way to spell newline). With my approach if line.startswith("==="): line = line.rstrip() + "===\n" you should always get ===test===(and then a newline) Peter -- http://mail.python.org/mailman/listinfo/python-list