Hi, I've found a work around, inspired from Rob Williscroft :
class ReMatch(object): """ Object to be called : 1st time : do a regexp.match and return the answer (args: regexp, line) 2nd time : return the previous result (args: prev) """ def __call__(self, regexp='', line='', prev=False): if prev: return self.prev_match self.prev_match = re.match(regexp, line) return self.prev_match re_match = ReMatch() if re_match(r'define\s+(\S+)\s*{$', line): m = re_match(prev=True) # do some logic with m elif re_match(r'include\s+(\S+)$', line): m = re_match(prev=True) # do some logic with m else # do some logic Hope this is efficient ... I guess yes. Cheers, Sam -- http://mail.python.org/mailman/listinfo/python-list