[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
[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
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
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
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
[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
[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
[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)
>
>
[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
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:
==
[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:
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
12 matches
Mail list logo