Re: Simple text parsing gets difficult when line continues to next line



Jacob Rael wrote:
[...]
I would line to identify if a line continues (if line.endswith('_'))
and concate with the next line:

line = line + nextLine

How can I get the next line when I am in a for loop using readlines?

Don't use readlines.

# NOT TESTED
program = open(fileName)
for line in program:
while line.rstrip("\n").endswith("_"):
line = line.rstrip("_ \n") + program.readline()
do_the_magic()

Cheers,
--
Roberto Bonvallet
.