> What you can't do (that I really miss) is have a tree of assign-and-test > expressions: > > import re > pat = re.compile('some pattern') > > if m = pat.match(some_string): > do_something(m) > else if m = pat.match(other_string): > do_other_thing(m) > else: > do_default_thing()
What you want is: for astring, afunc in ((some_string, do_something), (other_string, do_other_thing)): m = pat.match(astring) if m: afunc(m) break else: do_default_thing() -- http://mail.python.org/mailman/listinfo/python-list