[Python-ideas] if with as

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Mar 3 12:04:28 CET 2007


Josiah Carlson wrote:

> You could convert the code you have offered into the following:
> 
>     while pos < text_length:
>         match = name_re.match(text, pos) or \
>                 digit_re.match(text, pos) or \
>                 None
>         if match:
>             post = match.end()
>             do_something(match)
>         else:
>             pos += 1

I think the idea was that the do_something(match) could
be a different thing for each re.

--
Greg



More information about the Python-ideas mailing list