Carsten Haese <[EMAIL PROTECTED]> wrote: > If that's your only justification for this proposal, that's almost > certainly not enough to convince anybody of its necessity. Your code > example should be rewritten as a loop: > > match_actions = [(my_re1, action1), > (my_re2, action2), > ...] > > for my_re, action in match_actions: > if my_re.match(exp): > action(exp) > break >
Depending on what his 'do something with temp' actually was, it may or may not be easy to rewrite it as a for loop. However, even if a for loop isn't an obvious replacement other solutions may be appropriate such as combining the regular expressions to a single regex with named groups and/or using the command pattern. If assignment was an expression that only addresses one problem with the sample code. It still leaves his code with excessive repetition and probably with an excessively long function that calls out to be refactored as a group of smaller methods. -- http://mail.python.org/mailman/listinfo/python-list