Johann C. Rocholl wrote:

> 
> How do you people handle this?

Usually we don't bothe too much. But it has been suggested to do something
like this:

class Matcher:
    def __init__(self, rex):
       self.rex = rex

    def match(self, s):
       self.m = self.rex.match(s)
       return not self.m is None

Then you can do

m = Matcher(rex)

if m.match(line):
    print m.m


Of course you can enhance the class mather so that all methods it does not
define by itself are delegated to self.m, which would be more convient. But
I'm currently too lazy to write that down :)
-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to