Re: Seeking assistance - string processing.

2006-11-14 Thread John Machin
[EMAIL PROTECTED] wrote: > Thanks Fredrik, Peter and John for your help. > > John, I especially enjoyed your line by line assasination of my code, > keep it up. > > I'm not a programmer, I dislike programming, I'm bad at it. I just > agreed to do this to help someone out, I didn't even know what p

Re: Seeking assistance - string processing.

2006-11-14 Thread Frederic Rentsch
[EMAIL PROTECTED] wrote: > I've been working on some code to search for specific textstrings and > act upon them insome way. I've got the conversion sorted however there > is 1 problem remaining. > > I am trying to work out how to make it find a string like this "===" > and when it has found it, I

Re: Seeking assistance - string processing.

2006-11-14 Thread billpaterson2006
Thanks Fredrik, Peter and John for your help. John, I especially enjoyed your line by line assasination of my code, keep it up. I'm not a programmer, I dislike programming, I'm bad at it. I just agreed to do this to help someone out, I didn't even know what python was 3 days ago. In case you wer

Re: Seeking assistance - string processing.

2006-11-14 Thread John Machin
John Machin wrote: >new = line[:-1] + "===\n" To allow for cases where the last line in the file is not terminated [can happen], this should be: new = line.rstrip("\n") + "===\n" # assuming you want to fix the unterminated problem. Cheers, John -- http://mail.python.org/mailman/l

Re: Seeking assistance - string processing.

2006-11-14 Thread billpaterson2006
Thanks so much, a really elegant solution indeed. I have another question actually which I'm praying you can help me with: with regards to the .jpg conversion to .jpg]] and .gif -> .gif]] this works, but only when .jpg/.gif is on it's own line. i.e: .jpg will get converted to: .jpg]] but I

Re: Seeking assistance - string processing.

2006-11-14 Thread John Machin
[EMAIL PROTECTED] wrote: > I've been working on some code to search for specific textstrings and > act upon them insome way. I've got the conversion sorted What does that mean? There is no sort in the computer sense, and if you mean as in "done" ... > however there > is 1 problem remaining. > > I

Re: Seeking assistance - string processing.

2006-11-14 Thread Peter Otten
[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/carriag

Re: Seeking assistance - string processing.

2006-11-14 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > 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) > >

Re: Seeking assistance - string processing.

2006-11-14 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I am trying to work out how to make it find a string like this "===" > and when it has found it, I want it to add "===" to the end of the > line. how about if line.startswith("==="): line = line + "===" or if "===" in line: # anywhere line

Re: Seeking assistance - string processing.

2006-11-14 Thread billpaterson2006
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: ==

Re: Seeking assistance - string processing.

2006-11-14 Thread Peter Otten
[EMAIL PROTECTED] wrote: > Thanks so much, a really elegant solution indeed. > > I have another question actually which I'm praying you can help me > with: > > with regards to the .jpg conversion to .jpg]] and .gif -> .gif]] > > this works, but only when .jpg/.gif is on it's own line. > > i.e:

Seeking assistance - string processing.

2006-11-14 Thread billpaterson2006
I've been working on some code to search for specific textstrings and act upon them insome way. I've got the conversion sorted however there is 1 problem remaining. I am trying to work out how to make it find a string like this "===" and when it has found it, I want it to add "===" to the end of t