Doing both regex match and assignment within a If loop?

Mitya Sirenef msirenef at
Fri Mar 29 14:49:34 CET 2013

On 03/29/2013 04:27 AM, Peter Otten wrote:
> (2)
 > import re
 > class Matcher:
 >     def __call__(self, expr, line):
 >         result = self.match = expr.match(line)
 >         return result
 >     def __getattr__(self, name):
 >         return getattr(self.match, name)

Perhaps it's a little simpler to do this?

>         self.match =  expr.match(line)
 >         return self.match


Lark's Tongue Guide to Python:

Frisbeetarianism is the belief that when you die, your soul goes up on
the roof and gets stuck.  George Carlin

More information about the Python-list mailing list