save match function instead of regexp object

This commit is contained in:
Guido van Rossum 1991-08-16 13:24:42 +00:00
parent 14d53bf164
commit dff84043e4
2 changed files with 4 additions and 4 deletions

View file

@ -4,14 +4,14 @@ import regexp
import string
def grep(expr, filename):
prog = regexp.compile(expr)
match = regexp.compile(expr).match
fp = open(filename, 'r')
lineno = 0
while 1:
line = fp.readline()
if not line: break
lineno = lineno + 1
res = prog.exec(line)
res = match(line)
if res:
#print res
start, end = res[0]

View file

@ -4,14 +4,14 @@ import regexp
import string
def grep(expr, filename):
prog = regexp.compile(expr)
match = regexp.compile(expr).match
fp = open(filename, 'r')
lineno = 0
while 1:
line = fp.readline()
if not line: break
lineno = lineno + 1
res = prog.exec(line)
res = match(line)
if res:
#print res
start, end = res[0]