Doing both regex match and assignment within a If loop?
Mitya Sirenef
msirenef at lightbird.net
Fri Mar 29 09:49:34 EDT 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
-m
--
Lark's Tongue Guide to Python: http://lightbird.net/larks/
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