Tom Tucker wrote:
Hello! How can I instruct Python to match on the current line and the
next line?
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()



match_one = None for line in open(...): match_two = re.search('^\tBLAH', line) if match_one and match_two: do_something() match_one = re.search('^Python', line)


Add a last_line variable as well if do_something() needs access to the line data.

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to