On 24Oct2012 15:37, Paul Rubin <[email protected]> wrote: | Cameron Simpson <[email protected]> writes: | > if re_FUNKYPATTERN.match(test_string) as m: | > do stuff with the results of the match, using "m" | | class memo: | def __call__(f, *args, **kw): | self.result = f(*args, **kw) | | m = memo() | if result(re_FUNKYPATTERN.match, test_string): | do stuff with the results of the match, | using "m.result" | | then | | if re_CONSTRUCT1.match(line) as m: | ... handle construct 1 ... | elif re_CONSTRUCT2.match(line) as m: | ... handle construct 2 ... | elif re_CONSTRUCT3.match(line) as m: | | becomes | | if m(re_CONSTRUCT1.match, line): | .. handle construct 1 ... | elif m(re_CONSTRUCT2.match, line): | .. handle construct 2 ...
Cute. Not sure I like it, but cute:-) -- Cameron Simpson <[email protected]> If you do not read the paper, you are uninformed. If you do read the paper, you are misinformed. - Mark Twain -- http://mail.python.org/mailman/listinfo/python-list
