On May 21, 3:12 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On May 21, 1:47 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > > > Although that solution is pretty, it is not the canonical solution > > because it doesn't cover the important case of "if" bodies needing to > > access common variables in the enclosing scope. (This will be easier > > in Python 3 with 'nonlocal', though.) The snippet posted by Diez is > > IMHO closer to a canonical solution to this FAQ. > > Hello everybody, > > thanks for the various answers. I'm actually pretty puzzled because I > expected to see some obvious solution that I just hadn't found before. > In general I find Python more elegant and syntactically richer than C > (that's where I come from), so I didn't expect the solutions to be a > lot more verbose and/or ugly (no offense) than the original idea which > would have worked if Python's assignment statement would double as > expression, as in C. > > Thanks again, > robert > > PS: Since I'm testing only three REs, and I only need the match > results from one of them, I just re-evaluate that one.
Is it really a lot to change to have it if my_re1.match(line): match = my_re1.match(line) elseif my_re2.match(line): match = my_re2.match(line) elseif my_re3.match(line): match = my_re3.match(line) ? That reads clearly to me... -- http://mail.python.org/mailman/listinfo/python-list