Kaydet (Commit) dff84043 authored tarafından Guido van Rossum's avatar Guido van Rossum

save match function instead of regexp object

üst 14d53bf1
...@@ -4,14 +4,14 @@ import regexp ...@@ -4,14 +4,14 @@ import regexp
import string import string
def grep(expr, filename): def grep(expr, filename):
prog = regexp.compile(expr) match = regexp.compile(expr).match
fp = open(filename, 'r') fp = open(filename, 'r')
lineno = 0 lineno = 0
while 1: while 1:
line = fp.readline() line = fp.readline()
if not line: break if not line: break
lineno = lineno + 1 lineno = lineno + 1
res = prog.exec(line) res = match(line)
if res: if res:
#print res #print res
start, end = res[0] start, end = res[0]
......
...@@ -4,14 +4,14 @@ import regexp ...@@ -4,14 +4,14 @@ import regexp
import string import string
def grep(expr, filename): def grep(expr, filename):
prog = regexp.compile(expr) match = regexp.compile(expr).match
fp = open(filename, 'r') fp = open(filename, 'r')
lineno = 0 lineno = 0
while 1: while 1:
line = fp.readline() line = fp.readline()
if not line: break if not line: break
lineno = lineno + 1 lineno = lineno + 1
res = prog.exec(line) res = match(line)
if res: if res:
#print res #print res
start, end = res[0] start, end = res[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment