> tbl = [(my_regex, doSomething), (my_regex2, doSomething2), (my_regex3,
> doSomething3)]
> for regex, fun in tbl:
> match = regexp.match(line)
> if match:
>fun(line)
>break
Thank you for the idea. This is a bit more difficult when functions need
to work with a common con
If it is just the indentation that is bothering you, you could do this:
match = "test"
if match == "1":
print "1"
elif match == "2":
print "2"
elif match == "test":
print "test"
On 4/2/07, Ernesto García García <[EMAIL PROTECTED]> wrote:
Hi experts,
How would you do this without the
On Apr 2, 4:20 pm, Ernesto García García
<[EMAIL PROTECTED]> wrote:
> Hi experts,
>
> How would you do this without the more and more indenting cascade of ifs?:
>
> match = my_regex.search(line)
> if match:
> doSomething(line)
> else:
> match = my_regex2.search(line)
> if match:
> doS
Ernesto García García <[EMAIL PROTECTED]> wrote:
> Hi experts,
>
> How would you do this without the more and more indenting cascade of
> ifs?:
>
> match = my_regex.search(line)
> if match:
>doSomething(line)
> else:
>match = my_regex2.search(line)
>if match:
> doSomething2(lin
Ernesto García García wrote:
> Hi experts,
>
> How would you do this without the more and more indenting cascade of ifs?:
>
> match = my_regex.search(line)
> if match:
> doSomething(line)
> else:
> match = my_regex2.search(line)
> if match:
> doSomething2(line)
> else:
> match = m
Hi experts,
How would you do this without the more and more indenting cascade of ifs?:
match = my_regex.search(line)
if match:
doSomething(line)
else:
match = my_regex2.search(line)
if match:
doSomething2(line)
else:
match = my_regex3.search(line)
if match:
doSom