[Tutor] problem solved
Kirk Bailey
idiot1@netzero.net
Fri May 2 02:03:01 2003
ok, here it goes.
string.find(bigstring, substring) returns a -1 if the substring is NOT found.
However, for a IF statement, a FALSE is a ZERO (0) and ONLY a 0 will do; a -1 is a TRUE,
which I played with interactively in python to test out.
Further, if the saught strung is found at THE VERY BEGINNING of the larger string, the
returned vaslue is ZERO, as python is zero baised.
So I wrote this wrapper:
def wrongline(s,ss): # converts the -1 to a ZERO (a NOT)
x=string.find(s, ss)# so we can use it in a IF statelemt!
x=x+1
return x # return the X value
#
so if the substring is not found, it returns a ZERO, and any other result, indicating a
HIT, returns a value greater than ZERO, allowing this simple function to drive a
IF/THEN/ELSE flow structure with no pain or strain at all
My program now works, thanks to brute force and persistance. May this effort humbly
offered to the community prove educational.
.
--
end
Respectfully,
Kirk D Bailey
Owner HowlerMonkey Email Services Company: http://www.howlermonkey.net/
Inventor of TinyList MLM list server: http://www.tinylist.org/
Consulting Grump: http://www.sacredelectron.org/
Remember: it is an ill wind that blows no minds. Fnord.