I find myself often using regular expressions in the following
pattern:
foo_re = re.compile(rfoo(bar))
# . . .
re_result = foo_re.search(line)
if re_result:
bar = re_result.group(1)
# . . .
But, I keep thinking this is awkward, and I would kind of like to have
the re object to cache its
Dan wrote:
I find myself often using regular expressions in the following
pattern:
foo_re = re.compile(rfoo(bar))
# . . .
re_result = foo_re.search(line)
if re_result:
bar = re_result.group(1)
# . . .
But, I keep thinking this is awkward, and I would kind of like to have
the
On Wed, 29 Aug 2007 17:45:36 -0400, Steve Holden wrote:
Dan wrote:
foo_re = re.compile(rfoo(bar))
# . . .
if foo_re.search(line):
foo_re.last_result().group(1)
If you wanted to implement this I don't really see why a method call is
necessary. It would surely only need to be a simple
On Wed, 29 Aug 2007 21:54:50 +, Dan Stromberg - Datallegro wrote:
I've long felt that publicly accessible attributes probably should be
syntactic sugared to look like accessor methods, a bit like how __add__
ends up being + - so that if your attribute ever needs to become methods
(say, it
Dan Stromberg - Datallegro wrote:
On Wed, 29 Aug 2007 17:45:36 -0400, Steve Holden wrote:
Dan wrote:
foo_re = re.compile(rfoo(bar))
# . . .
if foo_re.search(line):
foo_re.last_result().group(1)
If you wanted to implement this I don't really see why a method call is
necessary. It