[Tutor] Match on current line and next line. Possible?
Tom Tucker
tktucker at gmail.com
Tue Feb 8 16:34:32 CET 2005
Hello! How can I instruct Python to match on the current line and the
next line?
Assumptions;
- We are reading in one line at a time
BROKEN EXAMPLE (discussion)
######################
file = open('/somefile','r').readlines()
for line in file:
match_one = re.search('^Python', line)
match_two = re.search('^\tBLAH', line)
if match_one and nextline == match_two:
do_something()
Maybe this just isn't possible, since we are working line by line.
Any suggestions?
Tom
More information about the Tutor
mailing list