[Tutor] putting together commands
Terje Johan Abrahamsen
terjeja@hotmail.com
Wed, 16 Oct 2002 17:00:55 +0000
I am using the re module to find some text in a file. But, I do want the
program to find different things each time. As an example I have done this:
rrr = 'tore er en hund'
I want to find whether the text has re after to.
m = re.search('(?<=to)nd', rrr)
And the program finds it. But, if I want to find 50 things, and want to find
50 different things each time, it will be very timeconsuming to rewrite each
one. So I write:
p = 're.search(\'(?<='
q = 'hu'
r = ')nd\', rrr)'
a = p+q+r
And I change the q 50 times, or uses it as the input in def find(q)
But, as I expected, q is a string. I cannot run a string. How do I come
around this problem? Any suggestions?
_________________________________________________________________
Internet access plans that fit your lifestyle -- join MSN.
http://resourcecenter.msn.com/access/plans/default.asp